I know that some array functions, such as array_rand, work for objects as long as you put (array) in front of the object. In this case I am trying to get the ID of the
$this->id = end($this->log->r);
this returns all of the elements in the last element. I just want to know what the key of that element is. This is a JSON_decoded object.
end()sets the pointer to the last property defined in the object and returns its value.When the pointer is moved, you can call the
key()function to get the property nameOutputs
string 'last_property' (length=13)This functionality is identical for arrays How to get last key in an array