3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<< END 2x egg 2 - carrot cabbage 1x potato END; $lines = explode("\n", $str); $ingredients = Array(); foreach($lines as $line) { $matches = Array(); if(!preg_match("^(\d+)(\S+)$", $line, $matches)) array_push($ingredients, Array(1, $line)); else array_push($ingredients, Array(intval($matches[1]), $matches[2])); } var_dump($ingredients);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: preg_match(): No ending delimiter '^' found in /in/MZHKU on line 14 Warning: preg_match(): No ending delimiter '^' found in /in/MZHKU on line 14 Warning: preg_match(): No ending delimiter '^' found in /in/MZHKU on line 14 Warning: preg_match(): No ending delimiter '^' found in /in/MZHKU on line 14 array(4) { [0]=> array(2) { [0]=> int(1) [1]=> string(6) "2x egg" } [1]=> array(2) { [0]=> int(1) [1]=> string(10) "2 - carrot" } [2]=> array(2) { [0]=> int(1) [1]=> string(7) "cabbage" } [3]=> array(2) { [0]=> int(1) [1]=> string(9) "1x potato" } }

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:
97.3 ms | 403 KiB | 8 Q