0

I need a Help, i try to check the array value to another array value.The two array size many be different all the time.because the array get from the data base. Example

array A     array B    Result
  1          1,2,3      true
  1            2,3      false
  1            2        false
  1,2          2,3      false
  1,2,3        1        false
  2,3         2,3       true
  1,2,3       1,2,3     true

$arrayA=array(1,2);
$arrayB=array(1);

the array value same time different

 $arrayA=array(1);
 $arrayB=array(1,2,3); 

The array hole value in the second array then only return true. I need to check the all the value of array a to next array b. please help me.thank adv....

4

3 回答 3

1
$result = !array_diff($arrayA, $arrayB);
于 2012-08-27T04:21:57.000 回答
0

Something like this maybe?

<?php
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);

print_r($result);

Array
(
    [1] => blue
)
?>

You can get all the info HERE

于 2012-08-27T04:25:48.253 回答
0

just a rough idea,

<?
$arrayA=array(1);
 $arrayB=array(1,2,3); 
 $k=array_intersect($arrayA,$arrayB);
 print_r($k);
?>
于 2012-08-27T04:40:34.263 回答