I have a nested foreach loop going through 2 arrays with a conditional if - else
. When if returns a value the else statement is also still running, why is that?
//$global_plugins is an array
//$xml_plugins is a string
foreach($global_plugins as $key => $global_plugins){
foreach ((array) $xml_plugins as $key2 => $xml_plugins){
if (($global_plugins == $xml_plugins) && ($plugin_verso[$key] == $xml_plugin_version[$key2])){
echo 'Exact match';
}else{
echo 'Fuzzy match';
}
}
}
For this example the array has 10 values to match, when the if
returns an "Exact match" it should not also return "Fuzzy match", yet this is what is happening.
For 1 matching value I get the echo output: "Exact match" one time and "Fuzzy match" x 10