fork(6) download
  1. <?php
  2.  
  3. function strposNth($texto, $procurar, $n){
  4. switch($n){
  5. case $n === 0:
  6. return false;
  7. break;
  8. case $n === 1:
  9. return(strpos($texto, $encontrar) + 1);
  10. break;
  11. default:
  12. return(strpos($texto, $procurar, strposNth($texto, $procurar, $n - 1) +
  13. strlen($procurar)) + 1);
  14. break;
  15. }
  16. }
  17.  
  18. echo strposNth("overflow", "o", 2);
  19.  
  20.  
  21.  
Success #stdin #stdout #stderr 0.02s 24448KB
stdin
Standard input is empty
stdout
7
stderr
PHP Notice:  Undefined variable: encontrar in /home/85I0Ey/prog.php on line 9