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; } $result = []; foreach($resultArray as $item) { $result[] = [$item['title'], $item['colour']]; } // Now do whatever you want to do var_dump($resultArray); var_dump($result);
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" } } array(2) { [0]=> array(2) { [0]=> string(5) "First" [1]=> string(3) "red" } [1]=> array(2) { [0]=> string(6) "Second" [1]=> 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:
35.1 ms | 406 KiB | 5 Q