2

I am getting data into two arrays and i want to push that data into single array one by one. Let say i want to get first element from first array and first element from second array and then push that data into single array.

first array

$url = $a->attr['href'];
$lnk[] = ['url'=>$url];

second array

$img = $img->attr['src'];
$img[] = ['img'=>$img];

I want this

$data[] = ['url'=>$url, 'img'=>$img];
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141

1 Answers1

1

I assume the size is same so you can iterate over the length on any of the arrays.

$finalArray=[];
for($i=0;$i<count($lnk);$i++){
   $finalArray[] = ['url'=>$lnk[$i]['url'], 'img'=>$img[$i]['img']];
}
Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78