I have objects in an Array. I want to access those objects' properties, but I'm not having any luck.
class Article {
public $category;
public $title;
public $img;
public $location;
public $text;
public function __construct($category, $title, $img, $location, $text) {
$this->category = $category;
$this->title = $title;
$this->img = $img;
$this->location = "pages/" . $location;
$this->text = $text;
}
}
//db of articles
$runawayFive = new Article("news", "The Runaway Five Comes to Fourside", "img/BluesBrothers.jpg",
"runaway_five_comes_to_fourside.html",
"The Runway Five continues its nationwide tour, stopping in Fourside to perform at the world famous Topolla Theater. Previously, an unexpected delay caused the group to postpone its shows for over a week. The award-winning group was forced to speed ten days in neighboring town, Threed. Tunnels going to and from Threed were blocked, but no one really knows how or why." . "<br>"
."The Runaway Five will being playing at the Topolla Theater during Friday and Saturday night. Tickets are $20 per adult."
);
$articles = Array($runawayFive);
echo $articles[0]["title"];
I should have the title of the article echoed out, but I'm not getting anything. I can do var_dump($articles[0]) and return the object, but can't access its values.