Answers for "array_merge is used in a loop and is a resources greedy construction."

0

array_merge is used in a loop and is a resources greedy construction.

You can get the $arraysToMerge using the array_column() function on $users like
this:

$arraysToMerge = array_column($users, 'socialMediaAccounts');
$arraysMerged  = array_merge(...$arraysToMerge);

Matt suggested that you don't need to merge into an empty array, so I adapted 
the code to his suggestion.
Posted by: Guest on July-09-2021

Code answers related to "array_merge is used in a loop and is a resources greedy construction."

Browse Popular Code Answers by Language