/ * * * Find a positive number occurrence of the string n times * @param $ str * @param $ the Find * @param $ n * @return BOOL | int * / function str_n_pos ( $ str , $ the Find , $ n = 1 ) { $ pos_val = 0 ; for ( $ I =. 1; $ I <= $ n- ; $ I ++ ) { $ POS = the strpos ( $ STR , $ Find ); $ STR = substr ( $ STR , $ POS. 1 + ); $ pos_val = $ POS + $ pos_val +. 1 ; } return $ pos_val -. 1 ; } / * * * find the inverse number of occurrences of the string n * @param STR $ * @param Find $ * $ @param n- * @return BOOL | int * / function str_n_rpos ( $ STR , $ Find , $ n- =. 1 ) { $ pos_val = 0 ; for ( $ I =. 1; $ I <= $ n- ; $ I ++) { $pos = strrpos($str, $find); $str = substr($str, 0, $pos); $pos_val = $pos; } return $pos_val; }