Wie der Titel andeutet, ist meine Frage, wie ich eine PHP-Klasse in ein assoziatives Array konvertieren kann? Zum Beispiel habe ich
class MyObject {
private $size = null;
private $length = null;
private $width = null;
public function getSize(){
return $this->size;
}
public function setSize($size){
$this->size = $size;
}
public function getLength(){
return $this->length;
}
public function setLength($length){
$this->length = $length;
}
public function getWidth(){
return $this->width;
}
public function setWidth($width){
$this->width = $width;
}
}
//Now what i want is following
$abc = new MyObject();
$abc->width = 10;
$anArray = someFunction($abc);
//This should generate an associative array
//Now associative array is accessible
echo $anArray['width]; // 10