3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* -- remove from list because ambiguous about relating arrays on code/model: 2013 (MCVE) https://stackoverflow.com/q/20515416/2943403 - PHP merge two arrays on the same key (@Jon, @deceze, @MarcoS) 2013 (MCVE) https://stackoverflow.com/q/16541555/2943403 - Array merge at second level (@Toto, @Roopendra, @DieterGribnitz, @MaximKumpan, @ljubiccica) 2014 (MCVE) https://stackoverflow.com/q/24556922/2943403 - How to merge values of the second level of two arrays with different number of keys? (@Alma Do, @billyonecan) 2014 (MCVE) https://stackoverflow.com/q/25093780/2943403 - combine two array according to key position (@Gaurav, @SatishSharms, @K.Weber) 2014 (MCVE) https://stackoverflow.com/q/26222626/2943403 - PHP: Fast way to combine 2 arrays (insert every element from B into one specific element of A) (@SameerShemna, @MarinVartan) 2014 (MCVE) https://stackoverflow.com/q/26425452/2943403 - How to merge multidimensional arrays where only subarrays are affected? (@AnkurBhadania, @PedroAmaralCouto) 2015 (MCVE) https://stackoverflow.com/q/28745382/2943403 - How to put other elements of two array beside similar ones in PHP (@MarkBaker, @VivekVaghela, @MR__Cary) 2015 (MCVE) https://stackoverflow.com/q/27894857/2943403 - How can I combine or push an array into an existed array? (@sectus, @Sithu) 2015 (MCVE) https://stackoverflow.com/q/33200330/2943403 - want to merge arrays like array1[0]+array2[0] using php (@Jesse, @FrancisEytanDortort) 2016 (MCVE) https://stackoverflow.com/q/34993057/2943403 - PHP: merge unknown number of arrays (@MarkBaker, @JesusTheHun) show https://3v4l.org/MUoSV 2016 (MCVE) https://stackoverflow.com/q/36807532/2943403 - Merging two PHP arrays with same numeric key (@Barmar, @Webeng, @Muhammed, @Krunal)) 2016 (MCVE) https://stackoverflow.com/q/35583517/2943403 - PHP: Combining Arrays (@Don'tPanic, @VincentDecaux) 2016 (MCVE) https://stackoverflow.com/q/37829865/2943403 - How to merge two nested associative array with same indexes? (@RaviHirani, @Kulvar, @Suyash, @Aks) 2016 (MCVE) https://stackoverflow.com/q/37326921/2943403 - How to merge two arrays in php? (@AbraCadaver, @Peon, @sevavietl) 2017 (MCVE) https://stackoverflow.com/q/47583861/2943403 - How add new arrray Row in multidimensional Array PHP (@Don'tPanic, @ObsidianAge, @jh1711, @tdjprog, @futureweb) 2017 (MCVE) https://stackoverflow.com/q/45561981/2943403 - How to format an array in php (@ChetanAmeta) 2018 (MCVE) https://stackoverflow.com/q/48784099/2943403 - php array merge on key using multidimensional array (@Ynhockey, @Kevin Pimentel, @ShahnawazKadari) 2018 (MCVE) https://stackoverflow.com/q/52598957/2943403 - Merge two arrays in one, combining the data correspondingly (@Barmar, @Osama, @mkveksas) 2018 (MCVE) https://stackoverflow.com/q/52329306/2943403 - PHP - Merge looped arrays into one (@Elementary, @parpar) https://3v4l.org/5m9A2 2018 (nope) https://stackoverflow.com/q/48047886/2943403 - add item array in a exist array php (@splash58, @Patrick R, @BilalAhmed, @Mak, @TarangP) 2018 (nope) https://stackoverflow.com/q/52183268/2943403 - php array fusion line per line (@Elementary) 2019 (MCVE) https://stackoverflow.com/q/56254741/2943403 - PHP - Multidimensional array merge to one array (@prasanth, @dWinder, @YassineCHABLI) 2019 (MCVE) https://stackoverflow.com/q/54025378/2943403 - PHP Adding multidimensional arrays together (@jh1711, @IslamElHakmi) 2019 (MCVE) https://stackoverflow.com/q/54407795/2943403 - Merge two sub arrays (@Barmar) 2020 (MCVE) https://stackoverflow.com/q/63788642/2943403 - Join Two arrays (@Kevin, @u_mulder, @Skyd) 2020 (MCVE) https://stackoverflow.com/q/63846757/2943403 - How to merge two arrays into one and transpose the structure to simplify printing from a loop? (@mickmackusa, @nice_dev) 2021 (MCVE) https://stackoverflow.com/q/65868878/2943403 - How to merge arrays vertically in PHP? (@whyer) Related: 2014 (MCVE) https://stackoverflow.com/q/26369044/2943403 - Transforming array values in elements of a subarray using PHP (@starless, @AlbanPommeret) 2015 (MCVE) https://stackoverflow.com/q/32854594/2943403 - Merge two multidimensional arrays, preserve numeric keys, and combine values inside array 2022 (MCVE) https://stackoverflow.com/q/71036560/2943403 - Evenly push values from a flat array into same positioned rows of a 2d array 2012 (MCVE) https://stackoverflow.com/q/12118962/2943403 - Add column of values from one array to another 2017 (MCVE) https://stackoverflow.com/q/45147476/2943403 - Map/Merge data from a flat array into the rows of a 2d array (@mickmacksua, @SahilGulati, @SotirisKiritsis, @Mojtaba, @Danielius) 2018 (MCVE) https://stackoverflow.com/q/50077638/2943403 - Merge rows from two arrays which have different depths, but same count (@Eddie) 2019 (MCVE) https://stackoverflow.com/q/54881445/2943403 - How to merge two arrays same sized object's in PHP (cannot merge objects https://3v4l.org/20rvh) 2019 (MCVE) https://stackoverflow.com/q/59827610/2943403 - PHP array_merge on multi-dimensional Array */
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.19, 8.3.0 - 8.3.7

preferences:
87.92 ms | 402 KiB | 123 Q