Should also work: foreach(array_keys((array)$MyObject) as $key) Or: while(list($key) = each($MyObject))