3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '我上的发顺丰testse'; function StringToArray($str) { $result = array(); $len = strlen($str); $i = 0; while($i < $len){ $chr = ord($str[$i]); if($chr == 9 || $chr == 10 || (32 <= $chr && $chr <= 126)) { $result[] = substr($str,$i,1); $i +=1; }elseif(192 <= $chr && $chr <= 223){ $result[] = substr($str,$i,2); $i +=2; }elseif(224 <= $chr && $chr <= 239){ $result[] = substr($str,$i,3); $i +=3; }elseif(240 <= $chr && $chr <= 247){ $result[] = substr($str,$i,4); $i +=4; }elseif(248 <= $chr && $chr <= 251){ $result[] = substr($str,$i,5); $i +=5; }elseif(252 <= $chr && $chr <= 253){ $result[] = substr($str,$i,6); $i +=6; } } return $result; } var_dump(StringToArray($str)); var_dump(mb_strlen('test','utf-8')); ?>
Output for git.master, git.master_jit, rfc.property-hooks
array(12) { [0]=> string(3) "我" [1]=> string(3) "上" [2]=> string(3) "的" [3]=> string(3) "发" [4]=> string(3) "顺" [5]=> string(3) "丰" [6]=> string(1) "t" [7]=> string(1) "e" [8]=> string(1) "s" [9]=> string(1) "t" [10]=> string(1) "s" [11]=> string(1) "e" } int(4)

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:
51.49 ms | 402 KiB | 8 Q