3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = array('SS2014','SU2014','FW2014','SS2013','FW2013','NW2012'); $cleanUpResult = array(); $counter = 0; $previousYear = ''; $currentIndex = 10; $previousYear = '2014'; foreach($strings as $row){ // if($counter == 0){ // $previousYear = substr($row, -4); // } if($previousYear !== substr($row, -4)){ $currentIndex = $currentIndex + 10; } if($counter > 0){ $previousYear = substr($row, -4); } switch(substr($row, 0, 2)){ case 'SS': $cleanUpResult[$currentIndex + 1] = $row; break; case 'SU': $cleanUpResult[$currentIndex + 2] = $row; break; case 'FW': $cleanUpResult[$currentIndex + 3] = $row; break; case 'WI': $cleanUpResult[$currentIndex + 4] = $row; break; case 'XM': $cleanUpResult[$currentIndex + 5] = $row; break; case 'CO': $cleanUpResult[$currentIndex + 6] = $row; break; case 'NW': $cleanUpResult[$currentIndex + 7] = $row; break; } $cleanUpResult[] = $row; $counter++; } var_dump($cleanUpResult);
Output for git.master, git.master_jit, rfc.property-hooks
array(10) { [11]=> string(6) "SS2014" [12]=> string(6) "SU2014" [13]=> string(6) "FW2014" [14]=> string(6) "FW2014" [21]=> string(6) "SS2013" [22]=> string(6) "SS2013" [23]=> string(6) "FW2013" [24]=> string(6) "FW2013" [37]=> string(6) "NW2012" [38]=> string(6) "NW2012" }

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:
46.59 ms | 402 KiB | 8 Q