Array Complement : array_diff « Data Structure « PHP






Array Complement

 
<?php
$first = array('e', 'h', 'r', 'j', 'b');
$last = array('w', 'e', 'c');

$diff = array_diff($last, $first);

echo '<p>';
foreach ($diff as $v) { echo "{$v} "; }
echo "</p>\n";
?>
  
  








Related examples in the same category

1.array_diff
2.array_diff( ) function returns a new array containing all the values of array $arr1 that do not exist in array $arr2.