php method to add elements to an array: 1. Add one or more elements to the end of the array of the first parameter through the "array_push" function; 2. Add one or more elements to the array through the "$arr[]" method Add elements.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.
php How to add elements to an array?
PHP adds elements to an array
There are two ways for PHP to add elements to an array:
array_push() , $arr[]
The first one:
$arr = array(); array_push($arr, e1, e2 ... en);
$arr = array(); $arr[] = e1; $arr[] = e2; ... $arr[] = en;
PHP Video Tutorial"
The above is the detailed content of How to add elements to an array in php. For more information, please follow other related articles on the PHP Chinese website!