note 40657 added to language.types.array
| From: | jchase at solidmark dot com | Date: | Wed, 10 Mar 2004 20:51:21 +0000 |
| Subject: | note 40657 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66580@lists.php.net to get a copy of this message | ||
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];
?>
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40657
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40657&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40657&report=yes
Search -- http://master.php.net/manage/user-notes.php