How to check if a string starts with a substring in PHP

1 Answer

0 votes
$s = "php java c programming";
$substring = "php";


if (strpos($s, $substring) === 0) {
    echo "yes";
}
 else {
     echo "no";
}




/*
run:

yes
 
*/

 



answered Feb 28, 2019 by avibootz

Related questions

...