Re: Referencing returned array elements...
- From: "GS" <goldstandard@xxxxxxxxx>
- Date: Tue, 27 Jan 2009 22:36:13 -0800
"GS" <goldstandard@xxxxxxxxx> wrote in message news:edSfl.19699$ZP4.17605@xxxxxxxxxxxxxxxxxxxxxxx
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!
A quick follow-up...
$temp_var = $word->parent(); then.
$temp_var[0]->word produces the desired result in that the first word is output, but I am getting the following error with E_STRICT:
PHP Notice: Trying to get property of non-object
So obvioulsy I am not even doing the current referencing properly... help!
.
- References:
- Prev by Date: Referencing returned array elements...
- Next by Date: How to extract Arabic Text from PDF file
- Previous by thread: Referencing returned array elements...
- Next by thread: Re: Referencing returned array elements...
- Index(es):
Relevant Pages
|