I was trying to figure out how to normalize an array with numerical keys. Since I was doing for() for a lot of things, but only replacing it if the conditions were right, I wound up with off ball arrays I couldn't access. That being said, I looked for a method of normalizing the array and couldn't find one, so I built my own. I'm not sure how to go about making it recursive, but I didn't need that feature for my own, so I just went without recursion.



//This will take array([5] => "test1", [4] => "test2", [9] => "test3") into array([0] => "test1", [1] => "test2", [2] => "test3") so you can access it easier.

function normalize_array($array){

$newarray = array();

$array_keys = array_keys($array);

$i=0;

foreach($array_keys as $key){

$newarray[$i] = $array[$key];



$i++;

}

return $newarray;

}