3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[ { "1": "tag_es1;tag_es2;tag_es3", "2": "tag_en1;tag_en2;tag_en3" }, { "1": "tag_es1;tag_es2", "2": "tag_en1;tag_en2" } ]'; $result = []; foreach (json_decode($json, true) as $i => $row) { foreach ($row as $id => $delimited) { foreach (explode(';', $delimited) as $key => $value) { $result[$i][$key][$id] = $value; } } } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 0 => array ( 1 => 'tag_es1', 2 => 'tag_en1', ), 1 => array ( 1 => 'tag_es2', 2 => 'tag_en2', ), 2 => array ( 1 => 'tag_es3', 2 => 'tag_en3', ), ), 1 => array ( 0 => array ( 1 => 'tag_es1', 2 => 'tag_en1', ), 1 => array ( 1 => 'tag_es2', 2 => 'tag_en2', ), ), )

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