How can I use array outside of the foreach loop so that it gives the same result?
foreach($rows as $row){ $s = array($row['sub_name']); $m = array($row['mark_obt']); $show = array_combine($s,$m); echo '<br>'; print_r($show); echo '<br>'; }
Advertisement
Answer
You can do like this :
$new_array = array(); foreach($rows as $key => $row){ new_array[$key]['sub_name'] = $row['sub_name']; new_array[$key]['mark_obt'] = $row['mark_obt']; } echo '<br>'; print_r($new_array); echo '<br>';