I have this very very basic code
foreach ($formatted_results as $result) {
$result['profile_pic']="joe";//set all values to joe
var_dump( $result['profile_pic']);//prints joe
}
foreach ($formatted_results as $result) {
var_dump( $result['profile_pic']);//does not print joe!
}
where formatted_results is an array containing other arrays. Now as you can see, I am modifying in the first loop the value of every array within formatted_results to contain the name joe, and then I am printing that to make sure and sure enough, the print of the first loop returns "joe"
However, the value I set is not persisting somehow, as when I loop that same array again to check the inner values of its own arrays, it gives me the old value.
The code is exactly as I am displaying it here, there is nothing in between. I am guessing there is something about pointers that is eluding me here.
$result['profile_pic']&to reflect the changes made to the array elements.foreach($formatted_results as &$result)makes it work.