php - var with more than 100 names, check if any are present in a text -
i have variable more 100 names, this:
$var = "josh" . ";" . "chloe" . ";" . "marie" . ";" . "john" . ";"... and texts want if 1 name above present in texts:
$text1 = "this apple"; // nothing, no name here. $text2 = "marie beautiful"; marie in text2, want call function. if 1 name in $var in $text2 want call function actions this:
if name found{ function insert(); } some ideas how can check if 1 name in $var present in $text?
thank friends!
store names in array, not string:
$names = array('josh', 'chloe'); $text1 = 'marie beautiful'; foreach ($names $name) { if (stristr($text1, $name) !== false) { // name found. call function here } } if can't store names in array, explode string:
$names = explode(';', $var);
Comments
Post a Comment