The example in this article describes the technique of php implementing the subtraction operation of two arrays. Share it with everyone for your reference. The details are as follows:
This code passes in two arrays A and B and returns the result of A-B, that is, selecting the elements that exist in A but not in B
<?php function RestaDeArrays($vectorA,$vectorB) { $cantA=count($vectorA); $cantB=count($vectorB); $No_saca=0; for($i=0;$i<$cantA;$i++) { for($j=0;$j<$cantB;$j++) { if($vectorA[$i]==$vectorB[$j]) $No_saca=1; } if($No_saca==0) $nuevo_array[]=$vectorA[$i]; else $No_saca=0; } return $nuevo_array; } ?>
I hope this article will be helpful to everyone’s PHP programming design.