3v4l.org

run code in 300+ PHP versions simultaneously
<?php $response = [ 'id' => 10499478683521864, 'birthday' => '07/22/1983', 'email' => 'email@saya.com', 'first_name' => 'Alan', 'gender' => 'male', 'last_name' => 'Malmsteen', 'link' => 'https://www.facebook.com/app_scoped_user_id/1049213468352864/', 'location' => (object) [ 'id' => 102173722491792, 'name' => 'Jakarta, Indonesia' ], 'locale' => 'id_ID', 'middle_name' => 'El-nino', 'name' => 'Alan El-nino Malmsteen', 'timezone' => 7, 'updated_time' => '2015-05-28T04:09:50+0000', 'verified' => 1 ]; foreach ($response as $key1 => $value1) { if (is_scalar($value1)) { echo "Key1: $key1, Value1: $value1\n"; } else { foreach ($value1 as $key2 => $value2) { echo "Key1: $key1, Key2: $key2, Value2: $value2\n"; } } }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Key1: id, Value1: 10499478683521864 Key1: birthday, Value1: 07/22/1983 Key1: email, Value1: email@saya.com Key1: first_name, Value1: Alan Key1: gender, Value1: male Key1: last_name, Value1: Malmsteen Key1: link, Value1: https://www.facebook.com/app_scoped_user_id/1049213468352864/ Key1: location, Key2: id, Value2: 102173722491792 Key1: location, Key2: name, Value2: Jakarta, Indonesia Key1: locale, Value1: id_ID Key1: middle_name, Value1: El-nino Key1: name, Value1: Alan El-nino Malmsteen Key1: timezone, Value1: 7 Key1: updated_time, Value1: 2015-05-28T04:09:50+0000 Key1: verified, Value1: 1

preferences:
118.15 ms | 403 KiB | 122 Q