Php recursive method return value is null This post was last edited by lihaiboas1 from 2013-01-2813: 31: 03 function & nbsp; getcount ($ start, $ str) {echo & nbsp; search. $ str. & nbsp; appears & nbsp ;. $ start. & lt; br & gt; $ the finds php recursive method returns null.
This post was last edited by lihaiboas1 at 13:31:03
Function getcount ($ start, $ str ){
// Echo "search". $ str. "appears. $ start ."
";
$ Findstr = $ start. (string) (int) substr ($ start,-1) + 1 );
// Echo substr_count ($ str, $ findstr )."
";
If (substr_count ($ str, $ findstr) = 0 ){
Echo "matching ended". $ start ."
";
Var_dump ($ start );
Return $ start;
} Else {
Echo "match". $ findstr. ", continue recursive match
";
Var_dump ($ findstr );
Getcount ($ findstr, $ str );
}
}
$ A = "7641235123 ";
For ($ I = 0; $ I <10; $ I ++ ){
$ Str1 = getcount ($ I, $ );
Var_dump ($ str1); // why is null returned?
If (strlen ($ str1)> 1 ){
Echo "$ a repeated characters". $ str. "total". substr_count ($ a, $ str). "times
";
}
}
------ Solution --------------------
12 rows
Getcount ($ findstr, $ str );
Change
Return getcount ($ findstr, $ str );