3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $myarray = Array ( Array ( 'user_id' => 21, 'email' => 'momod@modara.com', 'brand' => Array ('GOFUEL_W','GOFUEL_USD_W')), Array ( 'user_id' => 22, 'email' => 'hemisphere@modara.com', 'brand' => Array ('GOFUEL_W')), Array ( 'user_id' => 23, 'email' => 'madoka@modara.com', 'brand' => Array ('GOFUEL_W','GOFUEL_USD_W','GOFUEL_BGD_W') ) ); foreach($myarray AS $subarray) { if($subarray['user_id'] == 22) { $subarray['brand'][] = "GO_FUEL_SGD_W"; } } print_r($myarray);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => Array ( [user_id] => 21 [email] => momod@modara.com [brand] => Array ( [0] => GOFUEL_W [1] => GOFUEL_USD_W ) ) [1] => Array ( [user_id] => 22 [email] => hemisphere@modara.com [brand] => Array ( [0] => GOFUEL_W ) ) [2] => Array ( [user_id] => 23 [email] => madoka@modara.com [brand] => Array ( [0] => GOFUEL_W [1] => GOFUEL_USD_W [2] => GOFUEL_BGD_W ) ) )