3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* The Euro sign--U+20AC--followed by " hi there", in UTF-8. */ $teststr = "\xe2\x82\xac hi there"; /* Split it into individual characters, passing the /u flag to tell PCRE to interpret the string as UTF-8. */ $testchars = preg_split('//u', $teststr, -1, PREG_SPLIT_NO_EMPTY); /* Get some output that should be equivalent. */ preg_match_all('/./u', $teststr, $matches); $goodtestchars = $matches[0]; /* The arrays should be the same length. */ print "This should be 1: '".(count($testchars) == count($goodtestchars))."'\n"; /* And the octet count of the first entry should be three for both arrays. */ print 'These both should be three: '; print strlen($testchars[0]).', '.strlen($goodtestchars[0]). "\n";
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
This should be 1: '1' These both should be three: 3, 3
Output for 4.3.5 - 4.3.11, 4.4.0 - 4.4.9
This should be 1: '' These both should be three: 12, 3
Output for 4.3.0 - 4.3.4
This should be 1: '' These both should be three: 1, 3

preferences:
207.37 ms | 401 KiB | 343 Q