PHP/String/String Find

Материал из Web эксперт
Перейти к: навигация, поиск

Finding a Substring Within a String with strstr()

<?
$membership = "pAB7";
if ( strstr( $membership, "AB" ) )
   print "Thank you. Don"t forget that your membership expires soon!";
else
   print "Thank you!";
?>



String find Demo

<?
$string_to_search = "showsuponceshowsuptwice";
$string_to_find = "up";
print("Result of looking for $string_to_find" . strstr($string_to_search, $string_to_find));
$string_to_find = "down";
print("Result of looking for $string_to_find" . strstr($string_to_search, $string_to_find));
?>