Ver originalforeach($matrizB as $llaveA => $valorA){ foreach($matrizA as $llaveB => $valorB){ if($valorA != $valorB){ $matrizB[$llaveB] = 0; } }}