fork download
  1. <?php
  2. function maior($x)
  3. {
  4. $index = -1;
  5. for ($i=0;$i<strlen($x);$i++)
  6. {
  7. if ($ultimo != $x[$i])
  8. {
  9. $ultimocount = $count;
  10. $count = 0;
  11. $ultimo = $x[$i];
  12. }
  13. else
  14. {
  15. $count++;
  16. if ($count > $ultimocount)
  17. $index = strpos($x, $x[$i]);
  18. }
  19. }
  20. return $index;
  21. }
  22.  
  23. $n = "abbcccddddeeeeeefffffffffggg";
  24. echo maior($n);
Success #stdin #stdout #stderr 0.01s 82880KB
stdin
Standard input is empty
stdout
16
stderr
PHP Notice:  Undefined variable: ultimo in /home/zuQ2OS/prog.php on line 7
PHP Notice:  Undefined variable: count in /home/zuQ2OS/prog.php on line 9