Skip to content
Advertisement

Tag: object

converting an object to an array in laravel

I’m trying to compare two arrays and use the difference of them to remove data from another array but as I use the resulting array to do a array_diff_key using an array_flip it returns; array_diff_key(): Expected parameter 1 to be an array, object given this is the code and I’ve tried converting the ‘unchecked cols’ to an array using toArray

Is there anyway to get/remove the first object item like array_shift does on array in PHP?

I retrieved data, with mysqli->fetch_object(), in PHP. How can I get the first item and remove it from the objects, like array_shift does to array? How to emulate array_pop on stdClass also? Something like: Preferably no other libraries, nor conversions between object and array needed. Answer This will net you the first key from the object property list https://www.php.net/manual/en/function.get-object-vars.php https://3v4l.org/BmpJ6

Advertisement