LMSouq
php-dev Open

Using dynamic variable names in PHP

US
user1159454
1 month ago
3 views
Problem Description
I'm trying to use dynamic variable names. So inside this loop I want to create `$file0`, `$file1`, and `$file2`: for($i=0; $i<=2; $i++) { $("file" . $i) = file($filelist[$i]); } var_dump($file0); The return is `null` which tells me it's not working. I have no idea what the syntax or the technique I'm looking for is here, which makes it hard to research. `$filelist` is defined earlier on.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base