Rechercher une fonction PHP

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

HashTable as Variable API
Prototype Description
void array_init(zval* pzval) initializes the variable as a HashTable, setting type and appropriate destructor function for the HashTable
void array_init_size(zval* pzval) initializes the variable as array_init with a minimum of size buckets

Note:

Do not squint too hard looking for array_destroy: to destroy a variable array you should call zval_ptr_dtor on the variable, if there are no other references to the variable it will result in the array being destroyed.

Indexed Arrays API
Prototype
int add_index_long(zval* pzval, ulong index, long value)
int add_index_null(zval* pzval, ulong index)
int add_index_bool(zval* pzval, ulong index, zend_bool value)
int add_index_bool(zval* pzval, ulong index, zend_bool value)
int add_index_resource(zval* pzval, ulong index, uint value)
int add_index_double(zval* pzval, ulong index, double value)
int add_index_string(zval* pzval, ulong index, char* string, zend_bool duplicate)
int add_index_stringl(zval* pzval, ulong index, char* string, uint length, zend_bool duplicate)
int add_index_zval(zval* pzval, ulong index, zval* value)
int add_next_index_long(zval* pzval, long value)
int add_next_index_null(zval* pzval)
int add_next_index_bool(zval* pzval, zend_bool value)
int add_next_index_resource(zval* pzval, uint value)
int add_next_index_double(zval* pzval, double value)
int add_next_index_string(zval* pzval, const char* string, zend_bool dulpicate)
int add_next_index_stringl(zval* pzval, const char* string, uint length, zend_bool duplicate)
int add_next_index_zval(zval* pzval, zval* value)
Associative Arrays API
Prototype
int add_assoc_long(zval* pzval, const char* key, long value)
int add_assoc_long_ex(zval* pzval, const char* key, uint klen, long value)
int add_assoc_null(zval* pzval, const char* key)
int add_assoc_null_ex(zval* pzval, const char* key, uint klen)
int add_assoc_bool(zval* pzval, const char* key, zend_bool value)
int add_assoc_bool(zval* pzval, const char* key, zend_bool value)
int add_assoc_bool_ex(zval* pzval, const char* key, uint klen, zend_bool value)
int add_assoc_resource(zval* pzval, const char* key, uint value)
int add_assoc_resource_ex(zval* pzval, const char* key, uint klen, uint value)
int add_assoc_double(zval* pzval, const char* key, double value)
int add_assoc_double_ex(zval* pzval, const char* key, uint klen, double value)
int add_assoc_string(zval* pzval, const char* key, const char* value)
int add_assoc_string_ex(zval* pzval, const char* key, uint klen, const char* value)
int add_assoc_stringl(zval* pzval, const char* key, const char* value, uint vlen, zend_bool duplicate)
int add_assoc_stringl_ex(zval* pzval, const char* key, uint klen, const char* value, uint vlen, zend_bool duplicate)
int add_assoc_zval(zval* pzval, const char* key, zval* value)
int add_assoc_zval_ex(zval* pzval, const char* key, uint klen, zval* value)

Note:

add_*_string functions that accept a parameter named duplicate, will duplicate the string with estrndup when duplicate is true

Note:

add_*_zval functions do not adjust the refcount of the value parameter

To perform more advanced operations on array variables we must use the HashTable API directly.

Rechercher une fonction PHP

Document créé le 30/01/2003, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/php-rf-internals2.variables.arrays.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : http://php.net

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

Table des matières Haut