3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = '[specs product="test" category="body"]'; $pattern = '/(?:\[(?=[^][]*])(\w+)|\G(?!^))\h+(\w+)="([^"]+)"/'; $strings = [ '[specs product="test" category="body"]', '[pricelist keyword="216"]', '[specs product="test2" category="network" key="value"]' ]; foreach($strings as $s) { if (preg_match_all($pattern, $s, $matches)) { unset($matches[0]); $matches = array_map('array_filter', $matches); print_r($matches); } }
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [1] => Array ( [0] => specs ) [2] => Array ( [0] => product [1] => category ) [3] => Array ( [0] => test [1] => body ) ) Array ( [1] => Array ( [0] => pricelist ) [2] => Array ( [0] => keyword ) [3] => Array ( [0] => 216 ) ) Array ( [1] => Array ( [0] => specs ) [2] => Array ( [0] => product [1] => category [2] => key ) [3] => Array ( [0] => test2 [1] => network [2] => value ) )

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:
123.72 ms | 407 KiB | 5 Q