How can this task be accomplished? The goal is to get array3. The first array of each element contains the ID of this element. The second array of an unknown number of elements contains IDs identical to those from the first array. How can I make the elements of the second array nested in the ID elements of the first?
<? $array1 = array( [0] => array( 'id' => 1 ), [1] => array( 'id' => 2 ), [n] => array( 'id' => n ), ); ?> <? $array2 = array( [0] => array( 'target_id' => 1 ), [1] => array( 'target_id' => 2 ), [2] => array( 'target_id' => 1 ), [3] => array( 'target_id' => n ), ); ?> <? $array3 = array( [0] => array( 'id' => 1, 'children' => array( [0] => array( 'target_id' => 1 ), [1] => array( 'target_id' => 1 ) ) ), [1] => array( 'id' => 2, 'children' => array( [0] => array( 'target_id' => 2 ) ) ), [n] => array( 'id' => n, 'children' => array( [0] => array( 'target_id' => n ) ) ), ); ?>
$array3- what should it look like? - Evgeny Nikolaev