3v4l.org

run code in 300+ PHP versions simultaneously
<?php function balancedTagCloud(array $values, array $priorities): array { $low = min($priorities) - 1; $high = max($priorities) - $low; return array_map( fn($v, $p) => sprintf( '<h%1$d>%2$s</h%1$d>', ceil(($p - $low) / $high * 6), $v ), $values, $priorities ); } $artist = ["the roots", "michael jackson", "billy idol", "more", "and more", "and_YET_MORE"]; $counts = [ 'original' => [5, 3, 9, 1, 1, 3], 'no_ones' => [5, 3, 9, 7, 7, 3], 'skewed' => [5, 3, 9, 7, 111, 3], 'all_same' => [5, 5, 5, 5, 5, 5], 'only_two' => [9, 20, 9, 20, 9, 20], ]; foreach ($counts as $count) { echo implode("\n", balancedTagCloud($artist, $count)); echo "\n---\n"; }
Output for 7.4.3, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
<h4>the roots</h4> <h2>michael jackson</h2> <h6>billy idol</h6> <h1>more</h1> <h1>and more</h1> <h2>and_YET_MORE</h2> --- <h3>the roots</h3> <h1>michael jackson</h1> <h6>billy idol</h6> <h5>more</h5> <h5>and more</h5> <h1>and_YET_MORE</h1> --- <h1>the roots</h1> <h1>michael jackson</h1> <h1>billy idol</h1> <h1>more</h1> <h6>and more</h6> <h1>and_YET_MORE</h1> --- <h6>the roots</h6> <h6>michael jackson</h6> <h6>billy idol</h6> <h6>more</h6> <h6>and more</h6> <h6>and_YET_MORE</h6> --- <h1>the roots</h1> <h6>michael jackson</h6> <h1>billy idol</h1> <h6>more</h6> <h1>and more</h1> <h6>and_YET_MORE</h6> ---
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.3.29
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')' in /in/1UgZT on line 8
Process exited with code 255.

preferences:
112.01 ms | 409 KiB | 5 Q