Meilleure réponse
Vous pouvez ajouter des éléments à un tableau vide de différentes manières en php. Par exemple. Vérifiez le code suivant.
 / / lets first create an empty array. we will use it in the rest of the example 
 $test\_array = array(); 
 //for numerically indexed array, you can add element like this. 
 $test\_array[] = ‘new element’; // string value 
 $test\_array[] = 123; // integer value 
vous pouvez également utiliser les fonctions array\_push et array\_unshift pour ajouter des éléments au tableau. Par exemple, pour pousser un ou plusieurs éléments à la fin du tableau
 array\_push($test\_array, ‘new element’, 123, "you can add one or more element using comma"); 
Pour ajouter un ou plusieurs nouveaux éléments au début du tableau,
 array\_unshift($test\_array, "value one", "value 2 and so on"); 
Pour ajouter de la valeur à un tableau associatif.
 $test\_array["key\_of\_your\_array"] = "value of the array"; 
 // or you can use this way if your value is an associative array 
 $another\_array = array("my\_array\_key" => "My array value", "another\_key" => "another value"); 
 $result = $test\_array + $another\_array; 
 // lets print the result 
 print\_r($result); 
 // you should see the result something like the below 
 Array 
 ( 
  [my\_array\_key] => My array value 
  [another\_key] => another value 
 ) 
vous pouvez également utiliser array\_merge pour ajouter une nouvelle valeur à lancien tableau. Je ne vais pas faire cette réponse très longue.
Vous devriez jeter un œil dans la doc php pour array.
PHP : Array Functions – Manual
et Vous pouvez également apprendre la dernière version de PHP gratuitement ici. PHP: la bonne voie
Jespère que vous avez votre réponse.
Réponse
Ceci est pour les tableaux indexés:
 //declare an array 
 $myArray = array(); 
 //add value to the array 
 $myArray[] = "value"; 
Pour les tableaux associatifs:
 $myArray = array(); 
 $myArray ["key"] = "value"; 
Terminé!