fork download
  1. <?php
  2.  
  3. $output = '';
  4. $input = str_split('123456');
  5. $length = count($input);
  6.  
  7. while(strlen($output) < $length) {
  8. $currLength = strlen($output);
  9. if($currLength % 2 === 1) {
  10. $output .= array_shift($input);
  11. }
  12. else {
  13. $output .= array_pop($input);
  14. }
  15. }
  16.  
  17. echo $output;
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
615243