Skip to content

Instantly share code, notes, and snippets.

@ruliarmando
Created March 11, 2014 01:23
Show Gist options
  • Save ruliarmando/9477797 to your computer and use it in GitHub Desktop.
Save ruliarmando/9477797 to your computer and use it in GitHub Desktop.
check array
<?php
$array1 = array(
array('b','d'),
array('c','a'),
array('b','d'),
array('a','d'),
array('c'),
array('c'),
array('a','d','e'),
array('d','b')
);
$array2 = array(
array('c'),
array('a','d'),
array('b','d'),
array('a','d','e')
);
foreach($array2 as $a2)
{
$item2 = implode(',', $a2);
foreach($array1 as $a1)
{
$item1 = implode(',', $a1);
$pos = strpos($item1, $item2);
if($pos !== false)
{
$found[$item2] = isset($found[$item2]) ? $found[$item2] + 1 : 1;
}
}
}
echo "<pre>";
print_r($found);
echo "</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment