Referencing returned array elements...
- From: "GS" <goldstandard@xxxxxxxxx>
- Date: Tue, 27 Jan 2009 21:40:00 -0800
Probably hvaing a major brain-cramp, but here's my problem.
Have a method to a 'word' object, parent() that returns an array of 'wrod' objects that are parents of the current object. i.e.
$word->parent()
returns
array(
[0]=>word Object([word]=>test [syllables]=>1)
[1]=>word Object([word]=>testing [syllables]=>2)
)
Anyways, trying to reference the array elements when calling the function directly, but not sure it's possible.
Here's how I can get it to work:
$temp_var = $word->parent();
then I can reference $temp_var[0] to get that specific object.
I WOULD like to 'chain' the statement a little more though, ala jquery, so I can do more in less space, i.e.
$word->parent()[0]
So I can then do perform other actions on the selected item in the same line, i.e.
$word->parent()[0]->siblings()
etc.
$word->parent()[0] is causing an error of course, just wondering if there is another way to refernce the elements directly after the function call.
Thanks!
.
- Follow-Ups:
- Re: Referencing returned array elements...
- From: "Álvaro G. Vicario"
- Re: Referencing returned array elements...
- From: GS
- Re: Referencing returned array elements...
- Prev by Date: Re: PHP preg replace question
- Next by Date: Re: Referencing returned array elements...
- Previous by thread: PHP preg replace question
- Next by thread: Re: Referencing returned array elements...
- Index(es):
Relevant Pages
|