3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_split_unicode($str, $l = 0) { if ($l > 0) { $ret = array(); $len = mb_strlen($str, "UTF-8"); for ($i = 0; $i < $len; $i += $l) { $ret[] = mb_substr($str, $i, $l, "UTF-8"); } return $ret; } return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY); } $s = '中华人民abc共和\x01国'; echo $s; print_r(str_split_unicode($s)); print_r(str_split_unicode($s, 3)); for($i =0 ; $i < length($s) ; $i++) {echo $sub_str = mb_substr($s, $i, 1);}
Output for git.master, git.master_jit, rfc.property-hooks
中华人民abc共和\x01国Array ( [0] => 中 [1] => 华 [2] => 人 [3] => 民 [4] => a [5] => b [6] => c [7] => 共 [8] => 和 [9] => \ [10] => x [11] => 0 [12] => 1 [13] => 国 ) Array ( [0] => 中华人 [1] => 民ab [2] => c共和 [3] => \x0 [4] => 1国 ) Fatal error: Uncaught Error: Call to undefined function length() in /in/Ss9Jl:18 Stack trace: #0 {main} thrown in /in/Ss9Jl on line 18
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
55.25 ms | 401 KiB | 8 Q