3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $radius = 3; $blank = ' '; for ($i = 1, $diameter = $radius * 2 - 1; $i <= $diameter; $i++) { $nums = range(1, $i); $nums = array_merge($nums, array_reverse(array_slice($nums, 0, -1))); $blanks = array_fill(0, $diameter - $i, $blank); $row = array_merge($blanks, $nums, $blanks); echo join($row); }
Output for 5.6.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
1 121 12321 1234321 123454321
Output for 5.3.0 - 5.5.35
1 121 12321 1234321 Warning: array_fill(): Number of elements must be positive in /in/6n08d on line 9 Warning: array_merge(): Argument #1 is not an array in /in/6n08d on line 10 Warning: join(): Argument must be an array in /in/6n08d on line 12
Output for 5.2.5 - 5.2.17
1 121 12321 1234321 Warning: array_fill(): Number of elements must be positive in /in/6n08d on line 9 Warning: array_merge(): Argument #1 is not an array in /in/6n08d on line 10 Warning: array_merge(): Argument #3 is not an array in /in/6n08d on line 10 Warning: join(): Argument must be an array in /in/6n08d on line 12
Output for 5.0.0 - 5.2.4
1 121 12321 1234321 Warning: array_fill(): Number of elements must be positive in /in/6n08d on line 9 Warning: array_merge(): Argument #1 is not an array in /in/6n08d on line 10 Warning: array_merge(): Argument #3 is not an array in /in/6n08d on line 10 Warning: join(): Argument to implode must be an array. in /in/6n08d on line 12
Output for 4.3.2 - 4.4.9
1 121 12321 1234321 Warning: array_fill(): Number of elements must be positive in /in/6n08d on line 9 123454321
Output for 4.3.0 - 4.3.1
1 121 12321 1234321 Warning: array_fill() [http://www.php.net/function.array-fill]: Number of elements must be positive in /in/6n08d on line 9 123454321