In PHP, I have created an array that stores values that need to be concatenated in numerous ways numerous times, and so have created an accompanying function to carry out the concatenation when it is required. However, the function does not seem to return the values of the array, but will return the plain text parts of the string:
$my_array = array ("id" => "test");
$test = "First part " . $my_array['id'];
echo $test; // <-- returns "First part test"
function concatenate(){
$test_2 = "First part " . $my_array['id'];
return $test_2;
}
$use_function = concatenate();
echo $use_function; // <-- returns "First part". Does not include array information.
Any ideas on why this is happening or better methods of approaching this would be much appreciated. Thanks.