3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ [ 'id' => '7ac648ce-18aa-11e9-b673-005056be36b2', 'answer' => '1', 'id_question' => '39', 'pi' => 'very good', 'ca' => NULL, 'pic' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'deadline' => NULL ], [ 'id' => '8653ef3d-18aa-11e9-b673-005056be36b2', 'answer' => '3', 'id_question' => '40', 'pi' => 'no problem', 'ca' => NULL, 'pic' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'deadline' => NULL ] ]; $array2 = [ [ 'id' => '38', 'question' => 'Kebersihan Meja Counter dan Meja Fincoy ', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ], [ 'id' => '39', 'question' => 'Seragam Sales Counter / Salesman* ', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ], [ 'id' => '40', 'question' => 'Kerapihan Sales Counter', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ], [ 'id' => '42', 'question' => 'Sales Guide', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ], [ 'id' => '43', 'question' => 'Product Card', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ], [ 'id' => '44', 'question' => 'Ketersediaan Buku Tamu', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ], [ 'id' => '45', 'question' => 'Ketersediaan Price List', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ], [ 'id' => '46', 'question' => 'Ketersedian Rak Brosur ', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ], [ 'id' => '47', 'question' => 'Ketersediaan Flyer*/brosur ', 'type' => 'NON DOS', 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0' ] ]; foreach ($array1 as $row) { $result[$row['id_question']]['id'] = $row['id']; $result[$row['id_question']]['id_question'] = $row['id_question']; $result[$row['id_question']]['type'] = null; $result[$row['id_question']]['answer'] = $row['answer']; $result[$row['id_question']]['pi'] = $row['pi']; $result[$row['id_question']]['ca'] = $row['ca']; $result[$row['id_question']]['pic'] = $row['pic']; $result[$row['id_question']]['deadline'] = $row['deadline']; $result[$row['id_question']]['new_deadline'] = $row['new_deadline']; $result[$row['id_question']]['reason'] = $row['reason']; $result[$row['id_question']]['notes'] = $row['notes']; $result[$row['id_question']]['last_root'] = null; $result[$row['id_question']]['exist_good'] = null; $result[$row['id_question']]['exist_not_good'] = null; $result[$row['id_question']]['not_exist'] = null; $result[$row['id_question']]['n_a'] = null; } foreach ($array2 as $row) { if (isset($result[$row['id']])) { // default elements already declared, just overwrite the nulls // $row['question'] is omitted from data $result[$row['id']]['type'] = $row['type']; $result[$row['id']]['last_root'] = $row['last_root']; $result[$row['id']]['exist_good'] = $row['exist_good']; $result[$row['id']]['exist_not_good'] = $row['exist_not_good']; $result[$row['id']]['not_exist'] = $row['not_exist']; $result[$row['id']]['n_a'] = $row['n_a']; } else { $result[$row['id']]['id'] = $row['question']; // no id, so use question $result[$row['id']]['id_question'] = null; $result[$row['id']]['type'] = $row['type']; $result[$row['id']]['answer'] = null; $result[$row['id']]['pi'] = null; $result[$row['id']]['ca'] = null; $result[$row['id']]['pic'] = null; $result[$row['id']]['deadline'] = null; $result[$row['id']]['new_deadline'] = null; $result[$row['id']]['reason'] = null; $result[$row['id']]['notes'] = null; $result[$row['id']]['last_root'] = $row['last_root']; $result[$row['id']]['exist_good'] = $row['exist_good']; $result[$row['id']]['exist_not_good'] = $row['exist_not_good']; $result[$row['id']]['not_exist'] = $row['not_exist']; $result[$row['id']]['n_a'] = $row['n_a']; } } var_export($result);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
array ( 39 => array ( 'id' => '7ac648ce-18aa-11e9-b673-005056be36b2', 'id_question' => '39', 'type' => 'NON DOS', 'answer' => '1', 'pi' => 'very good', 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 40 => array ( 'id' => '8653ef3d-18aa-11e9-b673-005056be36b2', 'id_question' => '40', 'type' => 'NON DOS', 'answer' => '3', 'pi' => 'no problem', 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 38 => array ( 'id' => 'Kebersihan Meja Counter dan Meja Fincoy ', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 42 => array ( 'id' => 'Sales Guide', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 43 => array ( 'id' => 'Product Card', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 44 => array ( 'id' => 'Ketersediaan Buku Tamu', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 45 => array ( 'id' => 'Ketersediaan Price List', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 46 => array ( 'id' => 'Ketersedian Rak Brosur ', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 47 => array ( 'id' => 'Ketersediaan Flyer*/brosur ', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array ( 39 => array ( 'id' => '7ac648ce-18aa-11e9-b673-005056be36b2', 'id_question' => '39', 'type' => 'NON DOS', 'answer' => '1', 'pi' => 'very good', 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 40 => array ( 'id' => '8653ef3d-18aa-11e9-b673-005056be36b2', 'id_question' => '40', 'type' => 'NON DOS', 'answer' => '3', 'pi' => 'no problem', 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 38 => array ( 'id' => 'Kebersihan Meja Counter dan Meja Fincoy ', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 42 => array ( 'id' => 'Sales Guide', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 43 => array ( 'id' => 'Product Card', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 44 => array ( 'id' => 'Ketersediaan Buku Tamu', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 45 => array ( 'id' => 'Ketersediaan Price List', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 46 => array ( 'id' => 'Ketersedian Rak Brosur ', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), 47 => array ( 'id' => 'Ketersediaan Flyer*/brosur ', 'id_question' => NULL, 'type' => 'NON DOS', 'answer' => NULL, 'pi' => NULL, 'ca' => NULL, 'pic' => NULL, 'deadline' => NULL, 'new_deadline' => NULL, 'reason' => NULL, 'notes' => NULL, 'last_root' => '1', 'exist_good' => '1', 'exist_not_good' => '0', 'not_exist' => '1', 'n_a' => '0', ), )

preferences:
242.9 ms | 409 KiB | 214 Q