Guardian-Mage Posted May 26, 2008 Share Posted May 26, 2008 My Current Code $i=0; while ($i < count($array)) { $data[$i][0] = $array[$i][0]; $data[$i][1] = $array[$i][1]; } All is good, but what is the array goes $array[0], $array[1], $array[7]. How can I make sure i get the contents of a full array without checking to see if the array is full. I don't want to check the array if it is $array[11001010100101] or $array[-1] (not sure if this is possible). I am using this for forms. My forms go <input type="text" name="qty[0]" /> <input type="text" name="qty[1]" /> Someone could easily edit this to screw up my script. Any help? Link to comment https://forums.phpfreaks.com/topic/107359-solved-navigating-arrays/ Share on other sites More sharing options...
BlueSkyIS Posted May 26, 2008 Share Posted May 26, 2008 a possibility: $a_keys = array_keys($array); foreach ($a_keys AS $a_key) { $data[$a_key][0] = $array[$a_key][0]; $data[$a_key][1] = $array[$a_key][1]; } but i guess if we're just copying the array, i might just go $data = $array; Link to comment https://forums.phpfreaks.com/topic/107359-solved-navigating-arrays/#findComment-550424 Share on other sites More sharing options...
Guardian-Mage Posted May 26, 2008 Author Share Posted May 26, 2008 Yeah, I just thought of it. Stupid I forgot about foreach, but thanks:) Link to comment https://forums.phpfreaks.com/topic/107359-solved-navigating-arrays/#findComment-550427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.