October 8th, 2012, 04:36 PM
Join Date: Sep 2012
Time spent in forums: 1 h 32 m 19 sec
Reputation Power: 0
PHP5 - Populating an array variable within a class
I have the following class....
public $Latitude = array(); //used to hold a list of positions
public $Longitude = array(); //same as above
When I want to add values to my class I've been trying the following, but my arrays are not being populated.
I get an error message ... array_push first argument should be an array....
$aStorm = new Storm();
$aStorm->StormName = 'test'; //works!
$aStorm->StormID = '4'; //works!
array_push($aStorm->Latitude, '23.4'); //does not work
array_push($aStorm->Longitude, '75.4'); //does not work
Please help with the correct way to populate the array.