color = $color; $this->model = $model; } public function message() { return "My car is a " . $this->color . " " . $this->model . "!"; } } $myCar = new Car("red", "Volvo"); $myCar = (array) $myCar; var_dump($myCar);?>
Objects converts into associative arrays where the property names becomes the keys and the property values becomes the values.
array(2) { ["color"]=> string(3) "red" ["model"]=> string(5) "Volvo" }