RE: [PHP] Creating multidimensional array dynamically
| From: | Jason Lotito | Date: | Thu, 06 Dec 2001 21:12:47 +0000 |
| Subject: | RE: [PHP] Creating multidimensional array dynamically | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76940@lists.php.net to get a copy of this message | ||
Something like this?
while( list( $name, $attempts, $completions, $yards, $td, $int ) =
mysql_fetch_row($res) )
{
$quarterbacks[$name] = array( "ATTEMPTS" => $attempts,
"COMPLETIONS" =>
$completions,
"YARDS" => $yards,
"TD" => $td,
"INT" => $int );
}
echo $quarterbacks["GARCIA"]["YARDS"];
Jason Lotito
jason@lehighweb.com
www.NewbieNetwork.net
> -----Original Message-----
> From: J. Roberts [mailto:jroberts@nuitari.com]
> Sent: Thursday, December 06, 2001 4:08 PM
> To: php-general@lists.php.net
> Subject: [PHP] Creating multidimensional array dynamically
>
>
> I can't seem to figure out how to create a multidimensional
> array from a database query. Here is an example of what I
> was looking for, using NFL quarterbacks as a statistical
> foundation... A record contains the following fields:
>
> NAME, ATTEMPTS, COMPLETIONS, YARDS, TD, INT
>
> Now I would like to be able to create an array with NAME as a
> key containing the array(ATTEMPTS, COMPLETIONS, YARDS, TD, INT).
>
> That way I would be able to do the following:
>
> echo $quarterbacks["GARCIA"]["YARDS"];
>
> and get the output of 3,100 or whatever the case may be.
>
> Thanks,
> -Jamison.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail:
> php-general-help@lists.php.net To contact the list
> administrators, e-mail: php-list-admin@lists.php.net
>