Re: Filtering arrays based on an object attribute



On Tue, 27 Feb 2007 23:23:14 +0100, laredotornado@xxxxxxxxxxx <laredotornado@xxxxxxxxxxx> wrote:

Hi,

I have an array filled with a particular type of object, which
contains an attribute "m_level", of integer type. What I want is to
get a subset of the array whose "m_level" attribute is equal to zero.
Is there a short way I can do this other than iterating through a
foreach / for loop?

I'm using PHP 4.4.4.

Thanks, - Dave


Did you try the array_filter() function?


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
.



Relevant Pages

  • Re: the necessity of Lisps Objects?
    ... Could you give me PHP code example snippets of how to: ... If you specify a number beyond the bounds of the integer type, ... I actually ran into this *feature* with some php code that looked like literal ... BTW, of the languages I have worked with, php seems to be unique in this *feature* ...
    (comp.lang.lisp)
  • Re: the necessity of Lisps Objects?
    ... integer type. ... Could you give me PHP code example snippets of how to: ...
    (comp.lang.lisp)
  • Filtering arrays based on an object attribute
    ... contains an attribute "m_level", of integer type. ... foreach / for loop? ... I'm using PHP 4.4.4. ...
    (comp.lang.php)
  • Re: product of odd integers
    ... You have to initialize product to 1 before entering the loop. ... in a 16-bit integer type; you may need to use type long int. ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • Re: Fast conversion from logical array to uint64/32 representation?
    ... Chessaurus wrote: ... fast way to convert this into a densely packed 32-bit integer type, ... do I need to loop through and use the bitset function? ...
    (comp.soft-sys.matlab)