Kleines Bsp
PHP-Code:
<?php
// String Array aus Excel
$strings = array(
'Hans Mueller',
'Dr. Anton Meier',
'Lisa Foo Prof. Dr.',
'Prof.Dr. Peter Muster'
);
// Namens Array aus der DB
$username = array(
'Mueller',
'Foo'
);
// Ergebis Array
$result = array();
// Diff Array
$resultDiff = array();
foreach($strings as $string)
{
foreach ($username as $user)
{
if(preg_match('/'.$user.'/', $string) && !in_array($string, $result)) array_push($result, $string);
}
}
$resultDiff = array_diff($strings, $result);
// Ausgabe Übereinstimmungen
echo 'Übereinstimmungen:';
echo '<pre>';
print_r($result);
echo '</pre>';
// Ausgabe Differenz
echo 'Differenz:';
echo '<pre>';
print_r($resultDiff);
echo '</pre>';
?>