3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<'EOF' text 16.11 19.22 21.33 text 17.11 23.22 25.33 27.55 text 18.11 26.22 EOF; echo 'Если не завязываться на количестве пробелов: ', PHP_EOL; $res = []; $lines = preg_split('#[\n\r]+#', trim($str)); foreach ($lines as $line) { $prices = preg_split('#\s+#', $line); $key = array_shift($prices); $res[] = ['key' => $key, 'prices' => $prices]; } echo json_encode($res), PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Если не завязываться на количестве пробелов: [{"key":"text","prices":["16.11","19.22","21.33"]},{"key":"text","prices":["17.11","23.22","25.33","27.55"]},{"key":"text","prices":["18.11","26.22"]}]

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:
69.6 ms | 401 KiB | 8 Q