php - Populate new array in for loop from two other arrays -
hi have been struggling population of array if can appreciated.
so have these 2 arrays $start_range[]
, $end_range[]
both contain respective values , both arrays of same size. example: $start_range[0] = 1000
, $end_range[0]=[2000]
. want fill new array range between numbers , keep respectiveness of values in example $new_array[0] = range($start_range[0],$end_range[0])
.
in moment using code here
for ($i=0; $i<sizeof($start_range); $i++) { $new_array[] = range($start_range[$i], $end_range[$i]); }
but problem generates arrays same data because loops through size of array. if size of array 4 generate 4 new exact same arrays. can't break out of loop generates arrays first columns of 2 arrays.
any solution?
would do?
$newarray = array(); foreach ($startarray $key => $value) { $newarray[$key] = range($startarray[$key], $endarray[$key]); }
Comments
Post a Comment