3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = 'some text [person name="Jackson" family="Smith"] text [vehicle brand="Benz" type="SUV" doors="4" seats="7"]'; foreach (preg_match_all('~(?:\G(?!^)|\[(\w+)) (\w+)="(\w+)"~', $text, $out, PREG_SET_ORDER) ? $out : [] as $matches) { if ($matches[1]) { $tag = $matches[1]; } $result[$tag][$matches[2]] = $matches[3]; } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'person' => array ( 'name' => 'Jackson', 'family' => 'Smith', ), 'vehicle' => array ( 'brand' => 'Benz', 'type' => 'SUV', 'doors' => '4', 'seats' => '7', ), )

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:
170.16 ms | 406 KiB | 5 Q