I have 3 strings, I would like to get only the equal strings of them, something like this:
$Var1 = \"Sant\";
$Array[] = \"Hello Santa Claus\"; // Name_1
$A
Your code will work too like below:-
foreach ($Array as $name)
{
if (stristr($name,$Var1)!==false)
{
echo $name;
echo PHP_EOL;
}
}
Output:- https://eval.in/812376
You can use php strpos() function also for this purpose
foreach($Array as $name)
{
if ( strpos($name,$Var1)!==false)
{
echo $name;
echo PHP_EOL;
}
}
Output:-https://eval.in/812371
Note:- In Both function the first argument is the string in which you want to search the sub-string. And second argument is sub-string itself.