vendredi 1 janvier 2016

Use a string in multiple conditions in a PHP IF statement

$mystring is declared as follows:

$mystring = "&& substr($losuj, 0, 1) == 'D' || substr($losuj, 0, 1) == 'K'";

I'd like to use $mystring (it's created by a loop earlier in my code) in the following statement:

while($row = mysql_fetch_array($wynik)) {
    $losuj = $row['wyraz'];
    if (!in_array($losuj, $losowe) 
    $mystring ){.......do something}
}

Is it even doable in PHP? I've tried echoing it normally, with {'$mystring'}, but I guess you can't interrupt loop statement just like that?

Aucun commentaire:

Enregistrer un commentaire