3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(6,8,9,8,9,8,5,4,4,9); function Counting($array){ $freq_data = array_count_values($array); $unique_elements = array_map('intval',array_keys($freq_data)); sort($unique_elements); $percentage_data = []; $total = count($array); foreach($unique_elements as $index => $element){ $current_percentage = $freq_data[$element] / $total; $percentage_data[$element] = $index > 0 ? $percentage_data[$prev_element] + $current_percentage : $current_percentage; $prev_element = $element; } return $percentage_data; } print_r(Counting($array));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [4] => 0.2 [5] => 0.3 [6] => 0.4 [8] => 0.7 [9] => 1 )

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:
133.31 ms | 405 KiB | 5 Q