- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
array_push() function in PHP
The array_push() function inserts one or more elements to the end of an array. It returns the new elements pushed into the array.
Syntax
array_push(arr, val1, val2)
Parameters
- arr − The specified array
- val1 − The value to be pushed
- val2 − The value to be pushed
Return
The array_push() function returns the new elements pushed into the array.
Example
The following is an example −
<?php $arr = array("table", "chair","pen", "pencil"); array_push($arr,"notepad", "paperclip"); print_r($arr); ?>
Output
The following is the output −
Array ( [0] => table [1] => chair [2] => pen [3] => pencil [4] => notepad [5] => paperclip )
Advertisements