PHP我有两个数组,我想从数组1中提取项目,如果它不在数组2中

Like the title says, I have two arrays and I just want to get everything from the first array that's not already in the second array. How do I do this?

Use array_diff:

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

print_r($result);

Result:

Array
(
    [1] => blue
)

See it working online: ideone

$x=array(1,2,3,4);
$y=array(3,4);

$z=array_diff($x,$y);
var_dump($z);

This will output array(1,2)