note 54356 deleted from internals2.ze1.zendapi by cmb
| From: | cmb@php.net | Date: | Sun, 10 Jan 2021 13:26:03 +0000 |
| Subject: | note 54356 deleted from internals2.ze1.zendapi by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216126@lists.php.net to get a copy of this message | ||
Note Submitter: josephmdaly at gmail dot com
----
Here is a quick example of how to read arrays passed as parameters:
int i;
/* data will be used to store one element on each iteration of a loop */
zval **data = NULL;
/* data_array is the array we are copying values into */
char **data_array = NULL;
/* Use zend_parse_parameters as you normally would with an 'a' in the type
string.
In this example it sets the variables data_arg and array_length
*/
data_array = emalloc(sizeof(char *) * array_length);
for (i = 0; i < array_length; i++) {
/* Get an element out of the hash table as a zval */
zend_hash_index_find(Z_ARRVAL_P(data_arg), i, (void **)&data);
/* Make sure the zval is a string */
convert_to_string(*data);
/* Convert the zval into a string and store it */
data_array[i] = Z_STRVAL_PP(data);
}