How to search for a specific text within a string in PHP

3 Answers

0 votes
$s = "PHP World!";
//    01234

echo strpos($s, "World");


/*
run:

4 

*/

 



answered Oct 31, 2015 by avibootz
0 votes
echo strpos("PHP World!", "World");


/*
run:

4 

*/

 



answered Oct 31, 2015 by avibootz
0 votes
$s = "PHP World!";
//    01234

echo strpos($s, "PHP");


/*
run:

0 

*/

 



answered Oct 31, 2015 by avibootz

Related questions

1 answer 299 views
1 answer 303 views
1 answer 256 views
3 answers 621 views
4 answers 544 views
...