SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $array = array_fill(0, 2, array_merge(
  2.    ['hello'],
  3.    ['by']
  4. ));
  5.  
  6. var_dump($array);
  7.    
  8. array(2) {
  9.   [0]=>
  10.   array(2) {
  11.     [0]=>
  12.     string(5) "hello"
  13.     [1]=>
  14.     string(2) "by"
  15.   }
  16.   [1]=>
  17.   array(2) {
  18.     [0]=>
  19.     string(5) "hello"
  20.     [1]=>
  21.     string(2) "by"
  22.   }
  23. }
  24.    
  25. array(4) {
  26.     [0]=>
  27.     string(5) "hello"
  28.     [1]=>
  29.     string(2) "by"
  30.     [2]=>
  31.     string(5) "hello"
  32.     [3]=>
  33.     string(2) "by"
  34. }
  35.    
  36. $values = new ArrayIterator(['hello', 'by']);
  37. $cycle  = new InfiniteIterator($values);
  38. $limit  = new LimitIterator($cycle,0, 4);
  39.  
  40. $array = [];
  41.  
  42. foreach ($limit as $value) {
  43.   $array[] = $value;
  44. }
  45.  
  46. var_dump($array);
  47.    
  48. array(4) {
  49.   [0]=>
  50.   string(5) "hello"
  51.   [1]=>
  52.   string(2) "by"
  53.   [2]=>
  54.   string(5) "hello"
  55.   [3]=>
  56.   string(2) "by"
  57. }
  58.    
  59. $array = array_merge(...array_fill(0, 2, array_merge(
  60.    ['hello'],
  61.    ['by']
  62. )));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top