[Phpwm] foreach
Phil Beynon
phil at infolinkelectronics.co.uk
Mon Dec 11 14:22:25 GMT 2006
I'm trying to parse a largeish array where I only want to find the first
instance of a value, capture it and swap a value into a smaller array, then
forget about parsing the rest of the array and get on with the next loop.
Can I put a foreach() in a while() and compare !== so that the result will
always be false will it trigger to endwhile when it does get match, thus not
parsing the whole array?
foreach($subdata as $nkey => $nvalue){ //small array
if($subdata[$nkey]['mident'] == "dummy_sub"){ //capture value key
//while(
foreach($rawdata as $rkey => $rvalue){ //look in big array
if($rawdata[$rkey]['main_index'] == $subdata[$nkey]['group_name']){
//comparison
$subdata[$nkey]['mident'] = $rawdata[$rkey]['main_id']; //replace
dummy_sub with value on true
} // end if
} // end foreach raw
//) // end while
} // end if
} // end foreach sub
Phil
More information about the Phpwm
mailing list