Jump to content

Array compare


sandy1028

Recommended Posts

Here's one way using the array_unique() and the array_diff() functions:

<?php
$array_1=array('A','B','C');
$array_2=array('A','A','B','B','A','B','A','B');
$array_3 = array_diff($array_1,array_unique($array_2));
echo '<pre>' . print_r($array_3,true) . '</pre>';
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/112551-array-compare/#findComment-578013
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.