Answers for "php find occurrence in string"

PHP
3

php count specific characters in string

<?php
//you can use the substr_count function
$str = "this is a test string"; 

echo substr_count($str, "s");  //Output: 4
?>
Posted by: Guest on May-23-2021
0

php find first occurrence in string

#You can use the strpos() function 

$cheese = "cheese";

strpos($cheese, 'h');

#Output: 1
Posted by: Guest on May-29-2021

Code answers related to "php find occurrence in string"

Browse Popular Code Answers by Language