Re: Referencing returned array elements...



"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!

.



Relevant Pages

  • Re: Scope of Variant / Array
    ... Since in the immediate window you can reference the array without the parent. ... I've got a form with a linked subform. ...
    (microsoft.public.access.formscoding)
  • Re: [PHP] unset in foreach breaks recrusion
    ... Thanks for the answer, the none recursion function is a good idea, ... Basically you can make it work if you would sort the array from ... small to high by parent value, but in my case I will get this array ... Now, about your other suggestion, yes, it will work without the reference. ...
    (php.general)
  • Referencing returned array elements...
    ... Have a method to a 'word' object, parent() that returns an array of 'wrod' objects that are parents of the current object. ... Anyways, trying to reference the array elements when calling the function directly, but not sure it's possible. ...
    (comp.lang.php)
  • Re: How can I take subarray without second array (drop other elements)?
    ... In mainfunction I have an array. ... I want to give to print_arrayfunction a reference to a part of array. ... I want to print @array elements from N to N+100 using this function, ... don't forget that modifying $# for an array will create undef ...
    (perl.beginners)
  • Re: Closing Child Window
    ... the child window automatically after displaying a message to the user. ... changed (I mean..some other page is now loaded in the parent browser.),and ... As any child windows are opened store the reference in an array. ...
    (microsoft.public.scripting.jscript)