Weird array question
Posted: Sat Mar 25, 2006 12:19 am
This might sound like I'm on drugs, but with the exception of contact C and some tylenol (I'm battling YACD - Yet Another Cold Damnit) I've had no such thing 
Anyways
I have a series of objects stored in an array:
The objects are NOT and CANNOT be assigned the index of their position in the array...
Using the following I have called one of the objects member functions:
When doSomething() is called, can you think of anyway, using PHP's RTTI or dynamic code execution abilities to somehow determine the index for $my_array for that given object?
For instance the above example, MyObject2 at index: 1 would need to somehow determine, using doSomething() that it was located at index: 1
Remember: I cannot pass any of these objects the index or anything that would indicate the position at which they reside...
Ideas???
Anyways
I have a series of objects stored in an array:
Code: Select all
$my_array[0] = new MyObject1();
$my_array[1] = new MyObject2();
$my_array[2] = new MyObject1();
$my_array[3] = new MyObject3();Using the following I have called one of the objects member functions:
Code: Select all
$ref =& $my_array[1];
$ref->doSomething();For instance the above example, MyObject2 at index: 1 would need to somehow determine, using doSomething() that it was located at index: 1
Remember: I cannot pass any of these objects the index or anything that would indicate the position at which they reside...
Ideas???