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
array(4) { [0]=> array(2) { [0]=> int(2) [1]=> string(3) "egg" } [1]=> array(2) { [0]=> int(2) [1]=> string(6) "carrot" } [2]=> array(2) { [0]=> int(1) [1]=> string(7) "cabbage" } [3]=> array(2) { [0]=> int(1) [1]=> string(6) "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:
41.77 ms | 402 KiB | 8 Q