3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = "Αυτή είναι η 1η δοκιμασία. Πρέπει να την ολοκληρώσω. Ώστε να μου δώσουν την 2η δοκιμασία. Και τέλος, την 3η δοκιμασία." ; $res = preg_split( "/(.*?\.*?)\../", $test, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); var_dump($res); $wordcounts = array_map(function ($item) { return count(preg_split('/\s+/', $item)); }, $res); var_dump($wordcounts);
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in /in/JNBYX on line 4 array(4) { [0]=> string(45) "Αυτή είναι η 1η δοκιμασία" [1]=> string(45) "Πρέπει να την ολοκληρώσω" [2]=> string(63) "Ώστε να μου δώσουν την 2η δοκιμασία" [3]=> string(49) "Και τέλος, την 3η δοκιμασία." } array(4) { [0]=> int(5) [1]=> int(4) [2]=> int(7) [3]=> int(5) }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in /in/JNBYX on line 4 array(4) { [0]=> string(45) "Αυτή είναι η 1η δοκιμασία" [1]=> string(45) "Πρέπει να την ολοκληρώσω" [2]=> string(63) "Ώστε να μου δώσουν την 2η δοκιμασία" [3]=> string(49) "Και τέλος, την 3η δοκιμασία." } array(4) { [0]=> int(5) [1]=> int(4) [2]=> int(7) [3]=> int(5) }
Output for 8.1.0 - 8.1.28
Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in /in/JNBYX on line 8 array(4) { [0]=> string(45) "Αυτή είναι η 1η δοκιμασία" [1]=> string(45) "Πρέπει να την ολοκληρώσω" [2]=> string(63) "Ώστε να μου δώσουν την 2η δοκιμασία" [3]=> string(49) "Και τέλος, την 3η δοκιμασία." } array(4) { [0]=> int(5) [1]=> int(4) [2]=> int(7) [3]=> int(5) }
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
array(4) { [0]=> string(45) "Αυτή είναι η 1η δοκιμασία" [1]=> string(45) "Πρέπει να την ολοκληρώσω" [2]=> string(63) "Ώστε να μου δώσουν την 2η δοκιμασία" [3]=> string(49) "Και τέλος, την 3η δοκιμασία." } array(4) { [0]=> int(5) [1]=> int(4) [2]=> int(7) [3]=> int(5) }

preferences:
201.56 ms | 403 KiB | 175 Q