Last active
January 8, 2025 16:23
-
-
Save EduardoSP6/a340d9abc8df018e48f29c78fe4f9d61 to your computer and use it in GitHub Desktop.
Method to convert object properties to array in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function __toArray(): array | |
{ | |
return call_user_func('get_object_vars', $this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment