By default, PHP's clone keyword just creates a shallow copy of an object, and doesn't work as desired if the object contains properties that are also objects, because it doesn't create real copies of those objects but rather just pointers to the initial version of them.
This function creates a deep clone of a PHP array or object, in which some of the array elements may be objects.