077 - strpos --- Find the position of the first occurrence
6
17
17
17
6
17
17
<?php // 077 - strpos --- Find the position of the first occurrence echo "</br><span class='myheading'>077-a - strpos --- Find the position of the first occurrence</span></br>"; $str = "Hello world. The world is nice"; $newStr1 = strpos($str, "world"); // find first position $newStr2 = strpos($str, "world", 10); // find first position form 10th index $newStr3 = strpos($str, "world", -20); //--- use negative start value $newStr4 = strrpos($str, "world"); // reversed search first occurance $newStr5 = stripos($str, "WORLD"); // not case sensitive $newStr6 = stripos($str, "WORLD", 10); // not case sensitive from 10 position $newStr7 = strripos($str, "WORLD"); // not case sensitive from last (reverse) echo '<pre>'; print_r($newStr1); echo '</pre>'; echo '<pre>'; print_r($newStr2); echo '</pre>'; echo '<pre>'; print_r($newStr3); echo '</pre>'; echo '<pre>'; print_r($newStr4); echo '</pre>'; echo '<pre>'; print_r($newStr5); echo '</pre>'; echo '<pre>'; print_r($newStr6); echo '</pre>'; echo '<pre>'; print_r($newStr7); echo '</pre>'; ?>