Arrays
|
|
|
|
<?php
/* Code by Serban Nicolae @2004 orfeu@as.ro
In this simple function you send two arrays and a number x
if x is 1 the function will return A+B ( reunion )
and if x is 2 will return A%B ( crossing )
*/
function oper_arrays($a ,$b, $x=1)
{
$ct1=count($a);
$ct2=count($b);
if ($x==1) { $c=$a;
for ($i=0 ; $i<$ct2 ; $i++)
{
$boo=0;
for ($j=0 ; $j<$ct1 ; $j++)
if ($b[$i]==$a[$j]) $boo=1;
if ($boo==0) $c[]=$b[$i];
}
return $c;
}
else { for ($i=0 ; $i<$ct1 ; $i++)
{
$boo=0;
for ($j=0 ; $j<$ct2 ; $j++)
if ($a[$i]==$b[$j]) $boo=1;
if ($boo==1) $c[]=$a[$i];
}
return $c;
}
}
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|