Divide value in foreach [closed]

0

I need to get the value of two different arrays and put them in the database, I tried with the code below, but I'm having difficulty separating the two values and adding each of the values to their respective database fields. p>

<?php

$array = array(12.1, 12.3, 18.32, 12.45, 1.5, 1.5);
$array2 = array(12.3, 2.3);

foreach(array_combine($array, $array2) as $key => $media) {
 $media = str_replace(",",".",$media); 
 $media_total = str_replace(",",".",$media_total); 
 var_dump($key, $media);
 var_dump($key, $media_total);
}
?>
    
asked by anonymous 24.02.2016 / 19:58

1 answer

1

Take the array_combine from within the foreach, because for each interaction it is matching the arrays again.

    
25.02.2016 / 20:51