Php Programming Code Examples
Php > Arrays Code Examples
Looping through two arrays
Looping through two arrays
I had two result sets (names) loaded into arrays, in this case $result_base and
$result_compare. I needed to check how similar each name was to every other name. In
order to do that, I used a nested while() function like so:
<?
while ($base = mysql_fetch_array($result_base)) {
mysql_data_seek($result_compare, 0);
while ($compare = mysql_fetch_array($result_compare)){
//code do do the comparison
}
}
//I'm sure there are more elegant ways to do this, but this worked for me.
?>