I've read a lot of posts related to array_walk but I can't fully understand why my code doesn't work. Here is my example.
The $new_array is empty when I do the var_dump, If I write var_dump on every iteration it shows some value, meaning that is treating the $new_array as a new variable on every iteration, I don't know why this is.. Does anyone know what is the error occurred in this code ?
$exploded = explode(",", $moveArray[0]);
print_r($exploded);
$new_array = array();
array_walk($exploded,'walk', $new_array);
function walk($val, $key, &$new_array){
$att = explode('=',$val);
$new_array[$att[0]] = $att[1];
}
var_dump($new_array);
use()language structure if you're using PHP >= 5.3use: 3v4l.org/kRYD7