Ohne viel Worte, einfach mal ein kleines Snippet – just use it
/**
* Create an array from all protected properties and returns it.
*
* @return array
*/
public function toArray()
{
$reflectionObj = new ReflectionClass(get_class($this));
$vars = $reflectionObj->getProperties(ReflectionProperty::IS_PROTECTED);
$array = array();
foreach (new RecursiveArrayIterator($vars) as $property) {
$name = $property->getName();
$tempPropertyName = trim($name, '_');
$tempPropertyArray = explode('_', $tempPropertyName);
$propertyName = '';
foreach ($tempPropertyArray as $part) {
$propertyName .= ucfirst($part);
}
$array[lcfirst($propertyName)] = $this->$name;
}
return $array;
}