3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "['text', 'te\\'\"x,2t', \"tex,t\", \"te\\\"x'#t\", true, True, [false, False, 100, +100], -100, + 10, - 20]"; $parts = preg_split('/\s*(\\\\["\']|"(?:\\\\"|[^"])*"|\'(?:\\\\\'|[^\'])*\')\s*|\s*([,\[\]])\s*/', $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); foreach ($parts as &$part) { if (preg_match("/^'(.*)'/", $part, $matches)) { $part = '"' . str_replace(array('"', "\\'"), array('\\"', "'"), $matches[1]) . '"'; continue; } $lpart = strtolower($part); if ($lpart == 'true' || $lpart == 'false') { $part = $lpart; continue; } if (preg_match('/^\+\s*(\d+)$/', $part, $matches)) { $part = $matches[1]; continue; } if (preg_match('/^-\s*(\d+)$/', $part, $matches)) { $part = '-' . $matches[1]; continue; } } $json = implode('', $parts); var_dump(json_decode($json));
Output for git.master, git.master_jit, rfc.property-hooks
array(10) { [0]=> string(4) "text" [1]=> string(8) "te'"x,2t" [2]=> string(5) "tex,t" [3]=> string(7) "te"x'#t" [4]=> bool(true) [5]=> bool(true) [6]=> array(4) { [0]=> bool(false) [1]=> bool(false) [2]=> int(100) [3]=> int(100) } [7]=> int(-100) [8]=> int(10) [9]=> int(-20) }

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:
29.76 ms | 406 KiB | 5 Q