3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = array("100_1", "100_2", "100_3", "101_1", "102_1", "102_2", "103_1", "103_2", "103_3", "104_1", "104_2"); $resultArray = array(); foreach($myArray as $entry) { $parts = explode("_", $entry); $found = FALSE; foreach($resultArray as $key => $resultEntry) { $resultParts = explode("_", $resultEntry); if($parts[0] == $resultParts[0]) { $found = TRUE; if((int)$parts[1] > (int)$resultParts[1]) { $resultArray[$key] = $entry; } } } if(!$found) { $resultArray[] = $entry; } } print_r($resultArray);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => 100_3 [1] => 101_1 [2] => 102_2 [3] => 103_3 [4] => 104_2 )

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:
49.42 ms | 401 KiB | 8 Q