Find indices of all occurrence of one string in other | PHP program to find indices of all occurrences of one string in other . ; Driver Code
< ? php function printIndex ( $ str , $ s ) { $ flag = false ; for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { if ( substr ( $ str , $ i , strlen ( $ s ) ) == $ s ) { echo $ i . " " ; $ flag = true ; } } if ( $ flag == false ) echo " NONE " ; } $ str1 = " GeeksforGeeks " ; $ str2 = " Geeks " ; printIndex ( $ str1 , $ str2 ) ; ? >