Daevid Vincent <mailto:[EMAIL PROTECTED]> on Thursday, April 07, 2005 1:13 PM said:
> I have an array of objects in PHP5. Each element's key is the > database row ID. > > I don't see a graceful way of finding the first element's key ID. [snip/] > My hack is to do this: > > foreach($fooObject as $key => $object) > { > $id = $key; > break; > } > > There has to be a better way. Something more elegant? While looking through the array functions I saw www.php.net/array_keys and thought of: <?php $keys = array_keys($object_array); $first_key = $keys[0]; ?> HTH, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php