I need to use a var in an array:
$var = "abcd";
array( 'Bla: bla', 'Blo: $var', 'Bli: bli');
I'm totally noob at php and google has not answered me...
Thanks,
I need to use a var in an array:
$var = "abcd";
array( 'Bla: bla', 'Blo: $var', 'Bli: bli');
I'm totally noob at php and google has not answered me...
Thanks,
As the others have said, you can use double quotes. Or you can technically use concatenation.
Double Quotes
array( 'Bla: bla', "Blo: $var", 'Bli: bli');
Concatenation
array( 'Bla: bla', 'Blo: ' . $var, 'Bli: bli');
As others have mentioned, you can use double quotes or concatenation. You can also use =>
and leave the variable outside of the quotes. For example:
$var = "blah";
$tester = array("boo"=>$var);
echo $tester["boo"]; // results in blah