3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "19018216307,Public,\,k]'=system1-system2,20230914143505.5,1-050000,No"; $pattern = <<<'REGEX' ~(?nxx) (?# modifiers: - inline n: parenthesis act as non-capturing groups - inline xx: spaces are ignored even in character classes - global A: all the matches have to be contiguous ) # pattern ( (?!\A) , \K | \A ) # not at the start with a commas or at the start without [^ , \\ ]* ( \\ . [^ , \\ ]* )* # field content (all that isn't a comma nor # a backslash, or an escaped character) # check ( \z (*:END) )? # define a marker if the end of the string is reached ~A REGEX; if (preg_match_all($pattern, $str, $m) && isset($m['MARK'])) { $result = array_map(fn($s) => strtr($s, ['\\\\' => '\\', '\\' => '']), $m[0]); print_r($result); }
Output for 8.1.24 - 8.1.33, 8.2.11 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Array ( [0] => 19018216307 [1] => Public [2] => ,k]'=system1-system2 [3] => 20230914143505.5 [4] => 1-050000 [5] => No )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
126.99 ms | 407 KiB | 5 Q