# PHP Extension & Arrays

- Thread: https://externals.io/message/15132
- Original archive: https://news-web.php.net/php.internals/15132
- Started by Chris Cranford on 2005-02-21T00:55:20+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #15132 — Chris Cranford — 2005-02-21T00:55:20+00:00

URL: https://externals.io/message/15132#15132

If I have a function that creates an array using add_assoc_string and then
adds it to the return value as add_property_zval, then how do I iterate over
the array and get the key and its value?

---

## #15133 — Joe Wollard — 2005-02-21T06:25:32+00:00

URL: https://externals.io/message/15132#15133 · In reply to: #15132

Chris,

I have a feeling I'm missing something but from what I'm gathering you 
want to be able to use the key of the array right along with the value. 
If that's what you need then the following should work:

$array = my_array_creating_function();

while(list($key, $val) = each($array)){
    echo "<br />" . $val . " is the value of " . $key;
}


Hope this was of some help!

Chris Cranford wrote:

>If I have a function that creates an array using add_assoc_string and then
>adds it to the return value as add_property_zval, then how do I iterate over
>the array and get the key and its value?
