I have two arrays,
$col = array(1,3,5,7,10...)
$data = array(1000 by 1000)
my program is:
$result = "";
for($i=0; $i<count($data); ++i){
for($j=0; $j<count($col); ++j){
$result .= ",".$data[$j]
}
$result .= "<br>";
}
echo $result;
Question is how can I
eliminate
theinner loop
or thej loop
?
Since the $col
array already know which index to pick, how can I format a variable of a variable so that j loop can be replace by
$result = $data[1st element in $col].","$data[2nd element in $col].","...;