How would I alter the below code so that it returns itself as an array. E.g using $this
public function toArray($data) {
if (is_array($data) || is_object($data)) {
$result = array();
foreach ($data as $key => $value){
$result[$key] = $this->toArray($value);
}
return $result;
}
return $data;
}
So that instead of passing the $data it converts all the private properties from $this into an array.
Something like this? get_object_vars()
also you can do like this(typecast):
Those two are a little different