fork download
  1. <?php
  2.  
  3. // your code goes here
  4. function stop_at($array) {
  5. $out = ‘’;
  6.  
  7. foreach($array as $item) {
  8. if ($item == 42) {
  9. break;
  10. }
  11. $out .= $item."\n";
  12. } return $out;
  13.  
  14. }
  15.  
  16. echo stop_at($arr);
  17.  
  18.  
Success #stdin #stdout #stderr 0.02s 23216KB
stdin
1
2
3
55
24
42
33
stdout
‘’
stderr
PHP Notice:  Undefined variable: arr in /home/58kt2Z/prog.php on line 16
PHP Notice:  Use of undefined constant ‘’ - assumed '‘’' in /home/58kt2Z/prog.php on line 5
PHP Warning:  Invalid argument supplied for foreach() in /home/58kt2Z/prog.php on line 7