3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getArray($fill,$noOfItem){ $maxIndex = floor($noOfItem/$fill); $rang = range(1,20); $finalArray = []; foreach($rang as $key => $val){ if($val % $maxIndex == 0 && array_sum($finalArray) < $fill){ $finalArray[] =1; }else{ $finalArray[] =0; } } print_r($finalArray); } getArray(6,20); getArray(8,20); getArray(19,20);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => 0 [1] => 0 [2] => 1 [3] => 0 [4] => 0 [5] => 1 [6] => 0 [7] => 0 [8] => 1 [9] => 0 [10] => 0 [11] => 1 [12] => 0 [13] => 0 [14] => 1 [15] => 0 [16] => 0 [17] => 1 [18] => 0 [19] => 0 ) Array ( [0] => 0 [1] => 1 [2] => 0 [3] => 1 [4] => 0 [5] => 1 [6] => 0 [7] => 1 [8] => 0 [9] => 1 [10] => 0 [11] => 1 [12] => 0 [13] => 1 [14] => 0 [15] => 1 [16] => 0 [17] => 0 [18] => 0 [19] => 0 ) Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 [13] => 1 [14] => 1 [15] => 1 [16] => 1 [17] => 1 [18] => 1 [19] => 0 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
172.37 ms | 407 KiB | 5 Q