there is:

class MyClass {} $a = new MyClass(); $b = new MyClass(); $d = new MyClass(); // etc... 

need to get something like:

  Array ( [0] => a [1] => b [3] => c // etc... ) 

Actually the question:
"How to get for the custom class MyClass list of objects created by it?", Is there a built-in php-function?

  • You can get it. What are you going to do with this list later? - Igor
  • Manipulate those objects that belong to the class MyClass - red_python am

1 answer 1

There is no built-in function, as far as I know, but it can be obtained through the $ GLOBALS superglobal variable.

Those. You can go through its elements in a loop and check whether an element is an object of a particular class.

  • This option left as a last resort, as more resource-intensive. It will require iteration of all variables and checking for the class name. I hope that someone will tell the built-in php function like ReflectionClass:: - red_python