Home > Backend Development > PHP Tutorial > PHP implements the method of subtracting two arrays, array subtraction_PHP tutorial

PHP implements the method of subtracting two arrays, array subtraction_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 09:56:55
Original
1065 people have browsed it

PHP implements the method of subtracting two arrays, array subtraction

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

<&#63;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;
}
&#63;>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/985263.htmlTechArticlephp method to implement subtraction operation on two arrays, array subtraction This article tells the example of php implementation on two arrays Techniques for performing subtraction operations. Share it with everyone for your reference. Specifically...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template