How to convert object data to array in cakephp 3?

Hi,

$attributeList = $this->Attributes->find(‘all’)
->select()
->contain([‘OptionsAttributes’ => function($q){
return $q;
}])->toArray();

How to convert object data to array?
I can convert using
$results = Hash::extract($attributeList, '{n}');
But I didn’t get contain([‘OptionsAttributes’]) value in array type.
How to convert it in an array?

the easy way …

$array = (array) $yourObject;
or
$array = json_decode(json_encode($nested_object), true);