What is the recommended method in PHP to extract data from object properties into an array?
When we have an object in PHP and we want to extract its data into an array, we can use the `get_object_vars()` function. This function returns an associative array containing all the properties of the object. By using this function, we can easily convert the object properties into an array for further manipulation or processing.
// Sample object
class Person {
public $name = 'John';
public $age = 30;
}
$person = new Person();
// Extract object properties into an array
$personArray = get_object_vars($person);
// Output the array
print_r($personArray);