0

These are the values to be displayed.

print_r(array_values($price));
print_r(array_values($mec_id));



Array ( [0] => 3100 [1] => 1600 [2] => 1600 [3] => 3100 [4] => 7500 [5] => 3500 ) 
Array ( [0] => 47 [1] => 41 [2] => 42 [3] => 45 [4] => 46 [5] => 48 ) 

I need to use two arrays at a time in the foreach loop.

$combined_array = array_combine($price, $mec_id);
 foreach($combined_array as $price=>$mec_id)
 {
    echo '<br>'.$mec_id.'-';
    echo $price.'<br>';
 }

But, after using array_combined method, it is combining the repeated values too. I think it is parsing the array from ending while combining.

45-3100

42-1600

46-7500

48-3500
Vyshnavi Samudrala
  • 477
  • 1
  • 4
  • 16

1 Answers1

-1

You need to change order in array_combine so:

$combined_array = array_combine($mec_id, $price);

because you can not create the same index twice

nospor
  • 4,150
  • 1
  • 14
  • 25