My data
1 : "aaa"
2 : "bbb"
2 : "ccc"
3 : "ddd"
4 : "eee"
4 : "fff"
4 : "ggg"
How could I keep these value in PHP array ? Are there any for-loop implementation example ?
[edited] How to make this array from my data via for-loop php ?
$array = array(
1 => array("aaa"),
2 => array("bbb", "ccc"),
3 => array("ddd"),
4 => array("eee", "fff", "ggg")
);
[edited#2] My real code:
$list = "SELECT.....";
$root = retrieve($list);
// $root is a array of the data from PostgreSQL;
foreach($root as $i => $v){
if(cond) {
$q = "SELECT ...(use variables from $root)";
$a = retrieve($q);
for($a as $j => $w) {
echo $index." ".$v["aid"]." ".$w['new_geom']."<br />";
}
//what this line printed, i simplified to the sample data above
$index++;
}
}
[edited#3] this is what it print
...
23 33 "aaa"
24 34 "bbb"
25 34 "ccc"
26 35 "ddd"
...