PHP array_push () function example tutorial and usage
Definition and usage
This array_push () function inserts an array at the end of one or more elements.
Syntax
Array_push (array, value1, value2 ...)
Parameter description
Array required. Specify an array
Value1 requirement. The specified value is increased.
Value2 is optional. The specified value is increased.
Tips and instructions
Tip: you can add a value or as many as you like.
Note: Even if you already have a string array key, your supplemental content will have a number key in allways. (See example 2)
<? Php $ a = array ("Dog", "Cat"); array_push ($ a, "Horse", "Bird"); print_r ($ a);?>
Output result.
Array ([0] => Dog [1] => Cat [2] => Horse [3] => Bird)
Let's look at an instance.
Arrays and string items:
<? Php
$ A = array ("a" => "Dog", "B" => "Cat ");
Array_push ($ a, "Horse", "Bird ");
Print_r ($ );
?>
Output
Array ([a] => Dog [B] => Cat [0] => Horse [1] => Bird)
Let's see an instance.