I am wondering why this doesnt work.
As of at least PHP 5.3, a function or class method returning an object acts like an object.
<?php
class A {
function test() {
echo "Yay!";
}
}
function get_obj() {
return new A();
}
function get_array() {
return array("foo", "bar", "hallo", "world");
}
get_obj()->test(); // "works
echo get_array()[1]; // and this fails
?>
I found this at http://php.net/manual/en/functions.returning-values.php
would someone clarify why it doesn't work for arrays but works for objects.
EDIT:
added get_array()
get_array()code?