PHP’s variable variables will help you out here. You can use them by prefixing the variable with another dollar sign:
$foo = "Hello, world!";
$bar = "foo";
echo $$bar; // outputs "Hello, world!"
More Related Contents:
- How create an array from the output of an array printed with print_r?
- How i can earn variable from string in PHP? [closed]
- “Notice: Undefined variable”, “Notice: Undefined index”, “Warning: Undefined array key”, and “Notice: Undefined offset” using PHP
- How to include a PHP variable inside a MySQL statement
- How can I combine two strings together in PHP?
- Remove empty array elements
- Parse query string into an array
- How to add elements to an empty array in PHP?
- Array to String PHP?
- Mixing a PHP variable with a string literal
- Convert flat array to a delimited string to be saved in the database
- String with array structure to Array [duplicate]
- php implode (101) with quotes
- use strings to access (potentially large) multidimensional arrays
- How to split a long string without breaking words?
- String contains any items in an array (case insensitive)
- PHP variable interpolation vs concatenation [duplicate]
- Convert a String into an Array of Characters
- Merge array items into string
- How to cast array elements to strings in PHP?
- Search and replace multiple values with multiple/different values in PHP5?
- Explode string into array with no empty elements?
- Fastest way of deleting a value in a comma separated list
- PHP: Create an array for a range
- PHP get values from SimpleXMLElement array
- How to implode array with key and value without foreach in PHP
- How to convert array values to lowercase in PHP?
- How to cast variable to array
- Search and replace multiple values with multiple/different values in PHP?
- Check if string contains word in array [duplicate]