Advertisement
ShadowEmbrace

Integer Insertion

Nov 4th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. <?php
  2.  
  3. $line = array_map('intval', explode(' ', readline()));
  4.  
  5. $input = readline();
  6.  
  7. while ($input !== 'end') {
  8.     $number = intval($input);
  9.  
  10.     if (strlen($input) === 1) {
  11.         array_splice($line, $number, 0, $number);
  12.     } else {
  13.         $index = substr($input, 0, (strlen($input) - 1) * -1);
  14.         array_splice($line, intval($index), 0, $number);
  15.     }
  16.  
  17.     $input = readline();
  18. }
  19. echo implode(' ', $line);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement