Services webmasters
Partenaires
Jeux concours gratuits
 
API Zend pour les tableaux indexés (Partie 2)
<<<
Ajouter un élément dans un tableau associatif Ajouter un élément dans un tableau indexé
>>>

8.10.6 Tableaux
8.10 Créer des variables
8 Développer PHP 4.0
 Manuel PHP

API Zend pour les tableaux associatifs
API Zend pour les tableaux indexés (Partie 1)
API Zend pour les tableaux indexés (Partie 2)
->Ajouter un élément dans un tableau associatif
Ajouter un élément dans un tableau indexé

Ajouter un élément dans un tableau associatif

zval *new_array, *new_element;
char *key = "element_key";
      
MAKE_STD_ZVAL(new_array);
MAKE_STD_ZVAL(new_element);

if(array_init(new_array) == FAILURE)
{
    // gérer les erreurs ici
}

ZVAL_LONG(new_element, 10);

if(zend_hash_update(new_array->value.ht, key, strlen(key) + 1, (void *)&new_element, sizeof(zval *), NULL) == FAILURE)
{
    // gérer les erreurs ici
}
<< Ajouter un élément dans un tableau associatif >>
API Zend pour les tableaux indexés (Partie 2) Tableaux Ajouter un élément dans un tableau indexé
Services webmasters
Les manuels
 
CoursPHP.com - Reproduction interdite -