I have multiple foreach's parsing data that I need to compare with each other. For instance:
foreach ($xml_string->xpath('//location') as $character) {
$xml_name = $character->earthname;
$compare_remote = strtolower(preg_replace("/[^a-zA-Z0-9 ]/", "", $xml_name));
}
foreach ( $whatever as $key => $value ) {
foreach ($value as $pkey){
$value_name = $pkey["spacename"];
$compare_local = strtolower(preg_replace("/[^a-zA-Z0-9]/", '', $value_name));
}
}
How can I loop through both sets of foreach to compare all the values in $compare_remote
with the values in $compare_local
, I will probably be using levenshtein()
, but for the sake of this example anything will do.