3v4l.org

run code in 300+ PHP versions simultaneously
<?php function word_cloud($words, $div_size = 400) { $tags = 0; $cloud = "<div style=\"width: {$div_size}px\">"; /* This word cloud generation algorithm was taken from the Wikipedia page on "word cloud" with some minor modifications to the implementation */ /* Initialize some variables */ $fmax = 96; /* Maximum font size */ $fmin = 8; /* Minimum font size */ $tmin = min($words); /* Frequency lower-bound */ $tmax = max($words); /* Frequency upper-bound */ foreach ($words as $word => $frequency) { if ($frequency > $tmin) { $font_size = floor( ( $fmax * ($frequency - $tmin) ) / ( $tmax - $tmin ) ); /* Define a color index based on the frequency of the word */ $r = $g = 0; $b = floor( 255 * ($frequency / $tmax) ); $color = '#' . sprintf('%02s', dechex($r)) . sprintf('%02s', dechex($g)) . sprintf('%02s', dechex($b)); } else { $font_size = 0; } if ($font_size >= $fmin) { $cloud .= "<span style=\"font-size: {$font_size}px; color: $color;\">$word</span> "; $tags++; } } $cloud .= "</div>"; return array($cloud, $tags); } $words = ['una' = 1, 'dos' => 2, '3' => 3]; var_dump(word_cloud($words));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.230.0140.05912.40
5.4.220.0150.04712.40
5.4.210.0160.04512.40
5.4.200.0100.05312.40
5.4.190.0100.04812.40
5.4.180.0160.04312.40
5.4.170.0100.04912.41
5.4.160.0160.04212.40
5.4.150.0120.04612.40
5.4.140.0100.04212.09
5.4.130.0120.03812.07
5.4.120.0190.04912.04
5.4.110.0090.04412.03
5.4.100.0230.06212.03
5.4.90.0150.04612.03
5.4.80.0140.03912.04
5.4.70.0240.06612.03
5.4.60.0150.04512.03
5.4.50.0090.04612.02
5.4.40.0190.03812.01
5.4.30.0140.03812.01
5.4.20.0180.03412.00
5.4.10.0120.04212.01
5.4.00.0110.04311.50
5.3.280.0130.04512.71
5.3.270.0270.06012.72
5.3.260.0150.04312.72
5.3.250.0120.04512.71
5.3.240.0160.03912.72
5.3.230.0110.04312.71
5.3.220.0100.04512.68
5.3.210.0160.05412.68
5.3.200.0130.04012.68
5.3.190.0120.04212.68
5.3.180.0120.04212.67
5.3.170.0130.03812.67
5.3.160.0130.03912.68
5.3.150.0130.04212.67
5.3.140.0180.03612.66
5.3.130.0120.04312.66
5.3.120.0140.04412.66
5.3.110.0120.06112.66
5.3.100.0340.06612.13
5.3.90.0110.04112.10
5.3.80.0130.04112.09
5.3.70.0110.04312.09
5.3.60.0130.04112.08
5.3.50.0140.04112.02
5.3.40.0140.04212.02
5.3.30.0130.03811.98
5.3.20.0150.04111.76
5.3.10.0140.04311.73
5.3.00.0160.04711.71

preferences:
134.36 ms | 1394 KiB | 7 Q