Variables
Working with Arrays
Working with Arrays
Working with Arrays
Arrays are stored in HashTable strucures, and have
the zval type IS_ARRAY. The API functions for creating, destroying
and manipulating these structures as variables are documented here
and can be found in Zend/zend_API.h
Prototype | Description |
---|---|
void array_init(zval* pzval) |
initializes the variable as a HashTable , setting type and appropriate destructorfunction for the HashTable
|
void array_init_size(zval* |
initializes the variable as array_init with a minimum ofsize buckets |
Note:
Do not squint too hard looking for array_destroy:
to destroy a variable array you should callzval_ptr_dtor
on the variable, if there are no other
references to the variable it will result in the array being
destroyed.
Prototype |
---|
int add_index_long(zval* pzval, ulong index, |
int add_index_null(zval* pzval, ulong |
int add_index_bool(zval* pzval, ulong index, |
int add_index_bool(zval* pzval, ulong index, |
int add_index_resource(zval* pzval, ulong |
int add_index_double(zval* pzval, ulong |
int add_index_string(zval* pzval, ulong |
int add_index_stringl(zval* pzval, ulong |
int add_index_zval(zval* pzval, ulong index, |
int add_next_index_long(zval* pzval, long |
int add_next_index_null(zval* |
int add_next_index_bool(zval* pzval, |
int add_next_index_resource(zval* pzval, |
int add_next_index_double(zval* pzval, |
int add_next_index_string(zval* pzval, const |
int add_next_index_stringl(zval* pzval, |
int add_next_index_zval(zval* pzval, zval* |
Prototype |
---|
int add_assoc_long(zval* pzval, const char* |
int add_assoc_long_ex(zval* pzval, const |
int add_assoc_null(zval* pzval, const char* |
int add_assoc_null_ex(zval* pzval, const |
int add_assoc_bool(zval* pzval, const char* |
int add_assoc_bool(zval* pzval, const char* |
int add_assoc_bool_ex(zval* pzval, const |
int add_assoc_resource(zval* pzval, const |
int add_assoc_resource_ex(zval* pzval, const |
int add_assoc_double(zval* pzval, const |
int add_assoc_double_ex(zval* pzval, const |
int add_assoc_string(zval* pzval, const |
int add_assoc_string_ex(zval* pzval, const |
int add_assoc_stringl(zval* pzval, const |
int add_assoc_stringl_ex(zval* pzval, const |
int add_assoc_zval(zval* pzval, const char* |
int add_assoc_zval_ex(zval* pzval, const |
Note:
add_*_string functions that accept a parameter
named duplicate, will duplicate the string withestrndup
whenduplicate
is
true
Note:
add_*_zval functions do not adjust the refcount of
thevalue
parameter
To perform more advanced operations on array
variables we must use the HashTable API directly.