Cheers for your help. As I said I'm new to this and I'm a bit confused.
I have cars class now, It contains basic properties of the car, colour, make rego etc. Methods will be added.
I have a second file with a second class now called carList. This will be a list (array) of objects (cars) retrieved from a database. I want to drill into each object and get the colour or make etc.
Creating a car object is easy.
`$car = new cars();
$car->cost = 14000;
$car->make = "Honda";
$car->rego = "ABC1234";`
Now with my second class, I'm returning an array of data
`class carslist extends database {
public function getCars(){
$sql = "SELECT * FROM cars";
$result = $this->connect()->query($sql);
$numrows = $result->num_rows;
if ($numrows > 0){
while($row = $result->fetch_assoc()){
$data[] = $row;
}
return $data;
}
}
}
$ac = new carslist();
print_r( $ac->getCars() );
This returns an array of data but not a car object. Am i hopelessly lost on this topic. I think I know what I want to do but can't work out how.