You can use the PHP array_push()
function to insert one or more elements or values at the end of an array. Let’s try out an example and see how this function works:
PHP Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<html> <head> <title>Code4Example</title> </head> <body> <?php $skills = array("HTML5", "CSS3", "JavaScript"); echo "<pre>"; // Append array with new items array_push($skills, "jQuery", "PHP"); print_r($skills); ?> </body> </html> |
Output:
1 2 3 4 5 6 7 8 9 10 |
Array ( [0] => HTML5 [1] => CSS3 [2] => JavaScript [3] => jQuery [4] => PHP ) |