I'm trying to loop through a PHP array but I only ever get back my original data. I think it has something to do with when I break the loop
$newData = $this->seperateKeyValuePairs($data);
private function seperateKeyValuePairs($array)
{
foreach($array as $key => $item)
{
if( is_array($item) ) $this->seperateKeyValuePairs($item);
if( is_string($key) && $this->stringStartsWith($key, 'is_') ) {
$item = $this->makeBoolean($item);
}
}
return $array;
}
$itemto a value, but that doesn't update the original array. You probably wantforeach($array as $key => &$item), so that way you're using references and the array will get updated.