I am pretty new to php and am working on a project.
In the simplest form, for the time being, I need to:
make a blank array,
then make a class that holds an object with some properties
then push that class and it’s properties to the array.
Is this a thing? Is this possible?
For example, I have multiple events I need listed out with their title, time, date, and presenter. When I print the array, it should show all events with their information listed.
I’m just having problems figuring out how to put this all together.
Here is what I have going so far:
[php]$events = array();
class Tours {
public $title = ‘Guided Tours’;
public $date = “Tuesday”;
public $time = “1:00 pm”;
public $presenter = “Gallery Guides”;
}
class Medit {
public $title = ‘Mindful Meditation’;
public $date = “Wednesday”;
public $time = “12:30 pm”;
public $presenter = “Galleries”;
}
class Kids {
public $title = ‘Storytelling & Art’;
public $date = “First Fridays”;
public $time = “10:30 am”;
public $presenter = “Galleries”;
}
$tours = new Tours;
$medit = new Medit;
$kids = new Kids;
array_push(‘Tours’, ‘Medit’, ‘Kids’);
print $events;
?>[/php]
It might be a total disaster, but any help would be appreciate!
Here is the error message I am getting:
Warning: array_push() expects parameter 1 to be array, object given in /home/angelazer/angelaivycreative.com/php_practice/index.php on line 36
Array