Unless the user has a lot of baskets, I would assume you would just list all the baskets the user has as links on the web page or as a pop up menu. The value passed by the links or pop up would be the element number of the array item containing the desired basket.
To extract a basket by name I would say you could use array_search, but in looking into that function it appears to have changed through recent versions of PHP. In PHP 4.1 it doesn't search multi-dimensional arrays, I'm not sure about in 4.2.

But it's easy enough to create your own function to search the array. And you are right, the setup I recommended can get a bit kludgy. But if you "denormalize" the array structure it can get easy again. Just make the first element for each basket the name of basket.
$baskets[] = array("basketname1","item1","item2");
$baskets[] = array("basketname2","item1","item2","item3");
$baskets[] = array("basketname3","item1","item2",...);

You can use sort() to sort the array.

Hope that helps and sorry about steering you down the difficult path first.

On Thursday, January 23, 2003, at 09:05 AM, David T-G wrote:

Given the array you present above, how would you extract a basket by
name?  The closest I can come is to go and find the name and then
increment the ID by 1 and then get out that basket, which sounds like a
*huge* mess...

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to