Wrap them in {}
:
${"file" . $i} = file($filelist[$i]);
Working Example
Using ${}
is a way to create dynamic variables, simple example:
${'a' . 'b'} = 'hello there';
echo $ab; // hello there
More Related Contents:
- Does Perl have PHP-like dynamic variables?
- How to store variable value after clicking “Submit”?
- How can I combine two strings together in PHP?
- PHP Pass variable to next page
- Send JavaScript variable to PHP variable [duplicate]
- Access a JavaScript variable from PHP
- Mixing a PHP variable with a string literal
- Reading and Writing Configuration Files
- PHP variables in anonymous functions
- Access PHP var from external javascript file
- PHP variable variables
- How can I access a property with an invalid name?
- PHP check whether property exists in object or class
- Can PHP namespaces contain variables?
- PHP function use variable from outside
- JavaScript Dynamic Variable Names
- PHP variable interpolation vs concatenation [duplicate]
- Dynamic PayPal button generation – isn’t it very insecure?
- How to set $_GET variable
- Workaround for basic syntax not being parsed
- PHP pass variable to include
- Storing Form Data as a Session Variable
- In PHP, is there a short way to compare a variable to multiple values?
- How to concatenate PHP variable name?
- Dynamic static method call in PHP?
- Get all instances of a class in PHP
- PHP: Create an array for a range
- Convert a String to Variable
- Replacing variables in a string
- If you create a variable inside a if statement is it available outside the if statement?