PHP array to char **

php.internals

Christopher Kings-Lynne

21 years ago
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

Rasmus Lerdorf

21 years ago
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