I would like to search $string for occurrences of the contents of $array but am having trouble with the implode function returning the following:
preg_match(): Delimiter must not be alphanumeric or backslash
So in the example below $string will be searched for 'Empire' or 'Jedi'.
This is almost certainly something to do with escaping but I can't get my head round it.
Many thanks
$string = 'The Empire Strikes back';
$array = array (
0 => 'Empire',
1 => 'Jedi'
);
if (preg_match( implode(" ", $array), $string )) {
echo "A match was found.";
} else {
echo "A match was not found.";
}