note 30183 deleted from ref.array by sniper
| From: | sniper@php.net | Date: | Sat, 18 Oct 2003 18:01:56 +0000 |
| Subject: | note 30183 deleted from ref.array by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58827@lists.php.net to get a copy of this message | ||
Note Submitter: Frank
----
After doing a lot of research i discovered that multidimensional arrays did not work as some people
explained.
Suppose the table "Projecten" contains:
project_id,project_omschrijving
1,first
2,second
And using the next code
$proj_result = pg_query("SELECT * FROM \"Projecten\"")
or die (pg_last_error());
if ($myrow = pg_fetch_array($proj_result)) {
do {
$proj[][0]=$myrow["project_id"];
$proj[][1]=$myrow["project_omschrijving"];
} while ($myrow = pg_fetch_array($proj_result));
}
Would create an array:
$proj[0][0]=1
$proj[0][1]=first
$proj[1][0]=2
$proj[1][1]=second
I would then expect foreach( $proj as $s) to give me:
$s as an array containing(1,first)
and the next foreach loop would give me an array $s=(2,second). But this is not working here. It
returns (first)
So be carefull when using foreach and the other walkers of arrays when using mutliple dimension
arrays.
Be prepared to walk value by value and act accordingly.
This took me sometime to figure out.