3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('title1','title2','title2','title3','title4','title5','title5','title6','title6','title5'); sort($array); $unique_length = count( array_unique($array) ); $total_dupes = 0; $clean = array(); for ($i=0; $i<$unique_length; $i++) { $current = array_shift($array); if ($current === NULL)//already have all elements break; $found = 1; while (($key = array_search($current, $array)) !== FALSE) {//search for dupes $found++; unset($array[$key]); } if ($found == 1) array_push($clean, $current); else { $dupes = array(); for ($i=0; $i<$found; $i++) $dupes[] = $current; $total_dupes++; $clean['dupe'.$total_dupes] = $dupes; } } print_r($array); print_r($clean);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( ) Array ( [0] => title1 [dupe1] => Array ( [0] => title2 [1] => title2 ) [1] => title3 [2] => title4 [dupe2] => Array ( [0] => title5 [1] => title5 [2] => title5 ) [dupe3] => Array ( [0] => title6 [1] => title6 ) )

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.67 ms | 402 KiB | 8 Q