# PHP array to char **

- Thread: https://externals.io/message/15446
- Original archive: https://news-web.php.net/php.internals/15446
- Started by Christopher Kings-Lynne on 2005-03-15T01:45:25+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

---

## #15446 — Christopher Kings-Lynne — 2005-03-15T01:45:25+00:00

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

Hi,

I'm working on some improvements to the pgsql extension and I would like 
to know how to convert a zval* that points to a PHP array to a char** 
that I can pass to the pgsql API functions.  The API function takes 
const char** so it will not modify the string, but the string must exist 
for the duration of the API call...

I've been looking at other code that does similar things, but I can't 
help wondering if there is a simple, straightforward way of doing it?

Cheers,

Chris

---

## #15447 — Rasmus Lerdorf — 2005-03-15T01:46:33+00:00

URL: https://externals.io/message/15446#15447 · In reply to: #15446

Christopher Kings-Lynne wrote:
> Hi,
> 
> I'm working on some improvements to the pgsql extension and I would like 
> to know how to convert a zval* that points to a PHP array to a char** 
> that I can pass to the pgsql API functions.  The API function takes 
> const char** so it will not modify the string, but the string must exist 
> for the duration of the API call...
> 
> I've been looking at other code that does similar things, but I can't 
> help wondering if there is a simple, straightforward way of doing it?

Just look at ext/standard/array.c

There are dozens of examples of how to walk a HashTable in there.

-Rasmus
