3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = ' Hello 20.04.2016 🚩 my incredibleness face😘face is XYZ '; $words = preg_split('/\s+/', $text, 0, PREG_SPLIT_NO_EMPTY); $wordsLength = array_map('mb_strlen', $words); $lengthCounts = array_count_values($wordsLength); $defaultCounts = array_fill_keys(range(1,10), 0); $filteredCounts = array_intersect_key($lengthCounts, $defaultCounts); $gaplessCounts = array_replace($defaultCounts, $filteredCounts); var_export($words); echo "\n"; var_export($wordsLength); echo "\n"; var_export($lengthCounts); echo "\n"; var_export($defaultCounts); echo "\n"; var_export($filteredCounts); echo "\n"; var_export($gaplessCounts);
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 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
array ( 0 => 'Hello', 1 => '20.04.2016', 2 => '🚩', 3 => 'my', 4 => 'incredibleness', 5 => 'face😘face', 6 => 'is', 7 => 'XYZ', ) array ( 0 => 5, 1 => 10, 2 => 1, 3 => 2, 4 => 14, 5 => 9, 6 => 2, 7 => 3, ) array ( 5 => 1, 10 => 1, 1 => 1, 2 => 2, 14 => 1, 9 => 1, 3 => 1, ) array ( 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, ) array ( 5 => 1, 10 => 1, 1 => 1, 2 => 2, 9 => 1, 3 => 1, ) array ( 1 => 1, 2 => 2, 3 => 1, 4 => 0, 5 => 1, 6 => 0, 7 => 0, 8 => 0, 9 => 1, 10 => 1, )
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.

preferences:
172.35 ms | 408 KiB | 5 Q