3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'aaa 3', 'bbb 15', 'ccccc 3A', 'dddd 2412', 'eee fff 15', 'ggg 612', 'hhh iiiii 23B', ]; $regex = '#(?<word>\D+)\s(?<number>.+)#'; $results = []; foreach ($array as $line) { preg_match($regex, $line, $matches); $results[$matches['word']] = $matches['number']; } var_dump($results);
Output for git.master, git.master_jit, rfc.property-hooks
array(7) { ["aaa"]=> string(1) "3" ["bbb"]=> string(2) "15" ["ccccc"]=> string(2) "3A" ["dddd"]=> string(4) "2412" ["eee fff"]=> string(2) "15" ["ggg"]=> string(3) "612" ["hhh iiiii"]=> string(3) "23B" }

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