QUESTION
=======
I have a group of values in this sort of format:
$value[0] = "name";
$value[1] = "bob";
now, what i want to do is make the first element the name of a variable,
and the second value be the value for that variable, so i can do, for example:
<?
echo "hello, my name is $name"
?>
and it will output "hello, my name is bob".
Is there any way to accomplish this?
ANSWER
======
${$value[0]} = $value[1];
Now $name exists and is set to "bob";
(Rasmus)
Passing variables by reference. Categories : Variables , PHP Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP , PHP , HTML , PDF , Excel PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside. Categories : PHP , Arrays , Variables Initialize global variables for every field in a table.
This version requires that phplib is installed on your
server. Categories : Global Variables , MySQL , PHP , Variables A class to put get and post variables in hidden form
elements. Works on scalars, normal arrays, associative
arrays. Categories : Algorithms , Variables , Arrays , PHP , PHP Classes How to display a PHP variable value from a selectbox without reloading the
page by merging PHP and Javascript variables. Categories : PHP , Java Script , Variables How to pass an array to a function, or how to define a
function wich recieves an array. Categories : Variables , PHP , Arrays Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
Categories : PHP , Directories , Variables , Arrays Working with files - return an array of files within a directory Categories : PHP , Strings , Variables , Filesystem Working with files - putting file contents to a string / var Categories : PHP , Filesystem , Variables , Strings How to make sure a that $foo is from a cookie and not from the URI. Categories : PHP , Variables , Global Variables , Cookies Inline Scope Control - The inline class provides methods for creating and destroying local variable scopes. Simply put, local scopes are spaces where some or all of the global variables are temporarily hidden. Categories : PHP , PHP Classes , Variables A simple function to prevent undefined $_POST/$_GET/$_SESSION variable errors Categories : PHP , Variables , Errors and Logging Accessing GET and PUT variables with HTTP_GET_VARS on Win2K. Categories : PHP , Windows 2000 , Variables Make your PHP 4.1 (or higher) script compatible with PHP 4.0 (still used by some prviders) Categories : PHP , PHP Options and Info , Variables