fork download
  1. <?php
  2. function str_echo($str){
  3. $chars=preg_split('//u', $str, null, PREG_SPLIT_NO_EMPTY);
  4. $chars_amount=count($chars);
  5. $str1=$str2=$div_str="";
  6. function ___my_getspace($counter){
  7. $spaces_required=(int)log10($counter)+1;
  8. $space="";
  9. for ($i=0; $i<$spaces_required; $i++){
  10. $space.=" ";
  11. }
  12. return $space."|";
  13. }
  14. for ($i=0; $i<$chars_amount; $i++){
  15. $str1.=" ".$chars[$i].___my_getspace($i);
  16. $str2.=" ".$i." "."|";
  17. }
  18. $str1_len=count(preg_split('//u', $str1, null, PREG_SPLIT_NO_EMPTY));
  19. for ($i=0; $i<$str1_len; $i++){
  20. $div_str.="=";
  21. }
  22. echo "$str1\n$div_str\n$str2\n";
  23. }
  24.  
  25. str_echo("abcde548451551s");
  26. $arr=array("a","b","c");
  27. echo implode("",$arr);
  28. str_echo(implode("",$arr));
  29.  
Runtime error #stdin #stdout #stderr 0.01s 52488KB
stdin
Standard input is empty
stdout
 a | b | c | d | e | 5 | 4 | 8 | 4 | 5 | 1  | 5  | 5  | 1  | s  |
=================================================================
 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
abc
stderr
PHP Fatal error:  Cannot redeclare ___my_getspace() (previously declared in /home/3Eh9A9/prog.php:6) in /home/3Eh9A9/prog.php on line 6