Re: Multidimensional array
| From: | Paul Chvostek | Date: | Thu, 28 Nov 2002 18:01:54 +0000 |
| Subject: | Re: Multidimensional array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126525@lists.php.net to get a copy of this message | ||
A multidimensional array is just an array whose values are themselves
arrays. So ...
$thing="2002-11"; // or whatever
$issue=array();
$issue[$thing]=array();
$issue[$thing]['number']="this";
$issue[$thing]['headline']="that";
And if you ksort($issue), the key/value associations will be maintained;
you're just changing the order of the elements. If you want to sort by
other "fields", array_multisort() may be for you.
p
On Thu, Nov 28, 2002 at 09:11:03AM -0800, Mako Shark wrote:
>
> Here is a problem I'm having similar to somethnig
> someone just posted, but not quite the same. I'm not
> toooooo experienced with the intricacies and
> complications of arrays, but I have a bunch of fields
> like this for a magazine organizer (best way to put
> it, I guess):
>
> $issuenumber[]
> $issueheadline[]
> $issuewriters[]
> $issuemonth[]
> $issueyear[]
> $issuedescription[]
> among other fields.
>
> I would like to store this all in one multidimensional
> array, like
> $issue->number[]
> $issue->headline[]
> etc.
>
> What is the syntax? I'm bumbling around right now.
> Also, if I sort() the array by number, would the rest
> of the fields be properly sorted? I assume so, but
> don't want to find out the hard way that it doesn't.
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
Paul Chvostek <paul@it.ca>
Operations / Abuse / Whatever +1 416 598-0000
it.canada - hosting and development http://www.it.ca/