note 40657 deleted from language.types.array by nlopess
| From: | nlopess@php.net | Date: | Thu, 11 Mar 2004 15:00:40 +0000 |
| Subject: | note 40657 deleted from language.types.array by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66657@lists.php.net to get a copy of this message | ||
Note Submitter: jchase@solidmark.com
----
There is a clarification about array referencing that I thought was worth mentioning. I apologize
if I'm stupid:)
If you need to reference an array index using another array (like from a mysql result set), the
correct syntax is as follows:
<?php
//given $row[1] = 1
$arr[$row[1]] = $row[1];
?>
AND NOT:
<?php
//given $row[1] = 1
$arr[$row][1] = $row[1];
?>
Array keys that are arrays (as in a multidimensional array) are referenced this way but it's
totally different - e.g:
<?php
//this assumes that we are defining $arr as such:
$arr = array("row" => array(0 => 0, 1 => 1, 2 => 2));
echo $arr["row"][1];
?>