3v4l.org

run code in 300+ PHP versions simultaneously
<?php function printCharMostRepeated($str) { if (!empty($str)) { $max = 0; foreach (count_chars($str, 1) as $key => $val) if ($max < $val) { $max = $val; $i = 0; unset($letter); $letter[$i++] = chr($key); } else if ($max == $val) $letter[$i++] = chr($key); if (count($letter) === 1) echo 'The character the most repeated is "'.$letter[0].'"'; else if (count($letter) > 1) { echo 'The characters the most repeated are : '; $count = count($letter); foreach ($letter as $key => $value) { echo '"'.$value.'"'; echo ($key === $count - 1) ? '.': ', '; } } } else echo 'value passed to '.__FUNCTION__.' can\'t be empty'; } $str = 'ddaabbccccsdfefffffqqqqqqdddaaa'; printCharMostRepeated($str);
Output for git.master, git.master_jit, rfc.property-hooks
The characters the most repeated are : "d", "f", "q".

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:
42.15 ms | 1518 KiB | 4 Q