Re: Array Help Needed



Jerry wrote:
Hi,

I have an array of ORDER DETAILS (see below). I would like to pull out of
the order Object array all the [products] in the order that have the
[attributes] [option] equal to 'Subscription' (this example the order has 2
subscription products and 2 products that are not subscriptions, but other
orders may have more or less), and put them into a new array with the
following structure:


foreach($object->products as $product)
foreach($product[attributes] as $att)
if($att[option] == 'Subscription')
echo $product[name];

See http://www.php.net/foreach

You may want to make checks that you have arrays, as otherwise you may get a
not that nice surprise when an array hasn't been set.

--

//Aho
.



Relevant Pages

  • Re: Array Help Needed
    ... I have an array of ORDER DETAILS. ... the order Object array all the in the order that have the ... time of multiple news groups trying to give you an answer while one group ...
    (alt.php)
  • Re: Import from finance.yahoo.com
    ... containing tables of stock statistics, it runs down the page and pulls the ... You could do the same thing using the 'find' command and I guess not have to ... Using the find command might also allow you to pull in the whole page (using ... an array and then looping through the array. ...
    (microsoft.public.excel.programming)
  • Re: drive failure during rebuild causes page fault
    ... Pull a drive and rebuild onto hot spare. ... but not page fault when it's not / ... what's the story with the new array appearing when you ...
    (freebsd-stable)
  • Re: Cant reverse array of Integers ?
    ... as I'm running out of hair to pull out :-( ... The PixLine will typically contain a single value of 255 at a random ... glaringly obvious to a knowledgable delphi wizard:P The array is ...
    (alt.comp.lang.borland-delphi)
  • Re: [PHP] A no brainer...
    ... serialization is trivial for scalar data. ... you're talking about a large array. ... Pull all the records in one query at first request and keep the ... Now, to find an actual lookup, use a binary search with mysql_seek ...
    (php.general)