3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a1 = array( '0' => array( 'banner_details' => array( 'id' => 2, 'section_id' => 24 ), 'slide_details' => array( 0 => array( 'id' => 74, 'name' => 'Ads1' ), 1 => array( 'id' => 2, 'name' => 'Ads2' ) ) ), '1' => array( 'banner_details' => array( 'id' => 106, 'section_id' => 92 ), 'slide_details' => array( 0 => array( 'id' => 2001, 'name' => 'Adv1' ), 1 => array( 'id' => 2002, 'name' => 'Adv2' ) ) ) ); $s = []; foreach($a1 as $data){ if (isset($data['banner_details']['section_id'])){ $s[$data['banner_details']['section_id']] = []; if (isset($data['slide_details'])){ foreach($data['slide_details'] as $row){ $s[$data['banner_details']['section_id']][] = $row['id']; } } } } print_r($s);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [24] => Array ( [0] => 74 [1] => 2 ) [92] => Array ( [0] => 2001 [1] => 2002 ) )

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:
50.09 ms | 1420 KiB | 4 Q