note 13664 added to function.array.php
| From: | cid441 at hotmail dot com | Date: | Thu, 28 Jun 2001 01:34:29 +0000 |
| Subject: | note 13664 added to function.array.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14706@lists.php.net to get a copy of this message | ||
here is a nice example of a multidimentional array. some people like to call them hash tables
(it's a matrix). either way here's how they work.
<?
$foo = array('fruit' => array('yellow' => 'banana',
'orange' => 'orange',
'purple' => 'plumb'),
'flower' => array('yellow' => 'sun flower',
'red' => 'rose',
'purple' => 'iris'));
echo"<form name=\"pick\" action=\"$PHP_SELF\">
<font face=\"Verdana, Arial\" size=\"2\">Type?
<input type=\"text\" name=\"type\">
Color?
<input type=\"text\" name=\"color\">
<input type=\"submit\" name=\"submit\" value=\"hit
it!\"> <br>";
echo"last pick = " . $foo[$type][$color];
/*type indicates the first level array & color the second. it's really simple. pick fruit
as the type and purple as the color and you'll always get plumb as the answer */
?>
«°»
http://www.php.net/manual/en/function.array.php