Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $arr1 = [ 33 => [ 0 => 30319, 1 => 30318, 2 => 30315 ], 32 => [ 0 => 21300, 1 => 45988 ] ]; $arr2 = [ 33 => [ 0 => 50209, 1 => 50149 ], 34 => [ 0 => 12345 1 => 34567 ] ]; foreach($arr1 as $k=>&$v) { if(is_array($arr2[$k])) { $v = array_merge($v, $arr2[$k]); } } print_r($arr1);
Copy Clear