PHP/String/stristr

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

Detecting whether a string is contained in another string

 
<?php
$password="secretpassword1";
if (strstr($password,"password")){
    echo("Passwords cannot contain the word "password".");
}
else {
    echo ("Password accepted.");
}
?>



Using Substring Alternatives

 
//string strstr ( string haystack, string needle ) 
//string stristr ( string haystack, string needle ) 
<?php 
$url = "www.wbex.ru"; 
$domain = strstr ($url, "."); 
echo $domain; 
?>