PHP - strpos example

Find the position of the first occurrence of a substring in a string
    
    $string = 'hello world';
    $post = strpos($string, 'world'); // $pos = 6
    $post = strpos($string, 'o'); // $pos = 4
    
Ignoring anything before the offset
    
    $string = 'hello world';
    $post = strpos($string, 'o', 5); // $pos = 7
    

Comments