3v4l.org

run code in 500+ PHP versions simultaneously
<?php $item_list = array ( 'total_price' => 1200, 'item_1' => array ( 'item_name1' => 'xyz', 'item_price1' => 100.00 ), 'item_2' => array ( 'item_name2' => 'abc', 'item_price2' => 200.00 ), 'item_3' => null, 'item_4' => array ( 'item_name3' => 'aaa', 'item_price3' => 402.00 ) ); foreach ($item_list as $key => $item_details) { if (is_array($item_details)) { echo "$key:\n"; foreach ($item_details as $name => $value) { echo "\t$name: $value\n"; } } else { echo "$key: $item_details\n"; } }
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
total_price: 1200 item_1: item_name1: xyz item_price1: 100 item_2: item_name2: abc item_price2: 200 item_3: item_4: item_name3: aaa item_price3: 402

preferences:
35.75 ms | 1137 KiB | 7 Q