Advertisement
Guest User

pavel1

a guest
Apr 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. <?php
  2.  
  3. $root = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
  4.  
  5. $inserts = [1, 2];
  6.  
  7. foreach ($inserts as $insert) {
  8.     for ($i = 0; $i <= count($root); $i++) {
  9.         $root_instance = $root;
  10.         array_splice($root_instance, $i, 0, $insert);
  11.  
  12.         foreach ($inserts as $var) {
  13.             for ($y = 0; $y <= count($root) + 1; $y++) {
  14.                 $root_instance2 = $root_instance;
  15.                 array_splice($root_instance2, $y, 0, $insert);
  16.  
  17.                 echo implode(' ', $root_instance2) . '<br>';
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement