3v4l.org

run code in 300+ PHP versions simultaneously
<?php $post = [ 'id_228' => 228, 'title_228' => "First", 'colour_228' => 'red', 'id_229' => 228, 'title_229' => "Second", 'colour_229' => 'blue']; // Transform data into a proper format $resultArray = []; foreach($post as $key => $val) { $key = explode('_',$key); $resultArray[$key[1]][$key[0]] = $val; } // Now do whatever you want to do var_dump($resultArray);
Output for git.master_jit, git.master, rfc.property-hooks
array(2) { [228]=> array(3) { ["id"]=> int(228) ["title"]=> string(5) "First" ["colour"]=> string(3) "red" } [229]=> array(3) { ["id"]=> int(228) ["title"]=> string(6) "Second" ["colour"]=> string(4) "blue" } }

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:
60.82 ms | 402 KiB | 8 Q