Re: Arrays
| From: | Tim | Date: | Mon, 31 Jul 2000 21:18:54 +0000 |
| Subject: | Re: Arrays | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-1653@lists.php.net to get a copy of this message | ||
> you can mix indexed arrays and associative arrays together, so I could
have
> any array like this:
>
> fruit = array (
> 0 => "apple",
> 1 => "orange",
> 2 => "pear",
> "color" = > "orange",
> 'texture" => "bumpy");
>
> so, we have 5 elements in this array (0-4), if I wanted to get 'bumpy' and
> I knew it was at index 4 I could access it 2 ways:
> 1) $texture = $fruit[4];
> 2) $texture = $fruit[texture];
>
> so, using
> while(list($key, $val) = each($fruit))
> {
> the each statement looks at each element of the array, each
element
> has 2 parts, its index and its value,
> the first element has index 0 and value 'apple', the second
element
> has index 1 and value 'orange',
> so, using the above while loop with list and each, you can access
it
> element, $key becomes 0,1,2,'color','texture' and $val becomes
> 'apple',
> 'orange', 'pear', 'orange', 'bumpy' during its entire
> life-cycle (one at a
> time though)
> }
>
> does this make sense,
> /Cody
>
> BTW, if you have any more general PHP questions, please direct them to the
> PHP mailing list rather than the database PHP mailing list. Thanks
Thanks for all your help :o) I should be able to get it sorted now.
Sorry about posting to the wrong group... I got a little confused because
I'm using the array as part of a database script, but it's not actually
anything to do with databases in itself...