3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array("Papples", "Gelato", "Gelato", "Banana", "Papples","Papples"); $arr_count = array_count_values($arr); $new_arr = array(); foreach($arr_count as $key=>$val){ if($val > 1){ $k = 1; for($i=0; $i<$val; $i++){ if($i==0){ $new_arr[] = $key; }else{ $new_arr[] = $key.++$k; } } }else{ $new_arr[] = $key; } } echo "<pre>"; print_r($new_arr);
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [0] => Papples [1] => Papples2 [2] => Papples3 [3] => Gelato [4] => Gelato2 [5] => Banana )

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