I am trying to find the occurrence of a substring in an array. Here is the string:
$string = "🎥🎥🔥🔥🔥Watch the game at @TheGoalTX on #GoaltimeSaturdays!"
Here is the array:
$venues = array (
[ "name" => "McDonalds", "slogan" => "Im Lovin It" ],
[ "name" => "The Goal", "slogan" => "GoaltimeSaturday" ],
[ "name" => "McDonalds", "slogan" => "McRibs are back" ],
);
Im running an array search in which I want to run a script if either search condition is true:
foreach ($venues as $venue) {
if ((stristr($string,$venue['name'])) OR (stristr($string,$venue['slogan'])) !== false) {
include "do.stuff.php";
}
}
The two array rows with McDonalds obviously fails. No problem.
But for some reason, the search is failing for the "slogan" element "GoaltimeSaturday" and Im not quite sure why. It should meet the "if" criteria but "do.stuff.php" is never reached.
A little help here / any ideas? Are the ""🎥🎥🔥🔥🔥" emotes or the "#" or "@" characters in the string the issue perhaps? Im at a loss as to why Im not getting a true/positive search result in the foreach loop...
I appreciate the assistance on this...
Aucun commentaire:
Enregistrer un commentaire