I have an array where each value is assigned to a unique key. The following code works as I would expect.
<?php
//Assign array keys and values
$array = array(
1234 => "Some Value",
2214 => "Another Value",
3566 => "Yet Another Value"
);
//Define the $key
$key = '1234';
echo "$array[$key]";
?>
The problem occurs when I try to assign the value to a variable instead of echoing it.
<?php
//Assign array keys and values
$array = array(
1234 => "Some Value",
2214 => "Another Value",
3566 => "Yet Another Value"
);
//Define the $key
$key = '1234';
$new_var = $array[$key];
echo "$new_var";
?>
Any ideas why the first block of code would work and not the second?
Thanks!