troubleshooting Question

PHP MVC Basics OOP. How to return Array of Object class.

Avatar of glynco
glynco asked on
PHPScripting Languages
7 Comments1 Solution705 ViewsLast Modified:
Source code for Model View Controller Tutorial in PHP:

I was trying to replace this:
		//return array(
		//	"Jungle Book" => new Article("Jungle Booking", "R. Kipling", "2012-03-01", "A classic book.", ""),
		//	"Moonwalker" => new Article("Moonwalker", "J. Walker", ""),
		//	"PHP for Dummies" => new Article("PHP for Dummies")

with this:

// Return Array of the objects inside the client's container
$objs = $container->list_objects();


for ($i = count($objs)-1; $i >= 0; $i--) { 

$tempObject = new Article();
$tempObject -> Title=$objs[$i];
$tempObject -> Author="Testing Author";

$allArticles[$i] = $tempObject;


return array($allArticles);

But the results are not show. How can I also have the Title of the Article as variable instead of $tempObject.
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros