mardi 25 octobre 2016

If Elseif with foreach loop in php

How to check value of array contains in string or not with if else condition.

I know I can check it directly like

foreach($array as $arrayvalue)
{
if(strpos($string,$arrayvalue) !== false)
        echo "String contains array value";
}

But I have another conditions above that like.

if(some condtion){
        statements.....
}
elseif(here I want to check array value in string )
{
    some statements.. 
}
else 
{
        some statements... 
}

How can I write this in correct way.. ??

Update

I want to check array values contains in string or not. also above foreach condition is additionally I want to add in existing code.

Aucun commentaire:

Enregistrer un commentaire