- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The easiest way to concatenate two arrays in PHP?
Simply use, array_merge() to concatenate two arrays in PHP. Let’s say the following are out arrays −
$nameArray1 = array('John','David'); $nameArray2 = array('Mike','Sam');
Now, set both the above arrays in array_merge() to concatenate them.
The syntax is as follows −
The PHP code is as follows
<!DOCTYPE html> <html> <body> <?php $nameArray1 = array('John','David'); $nameArray2 = array('Mike','Sam'); $result = array_merge($nameArray1, $nameArray2); print_r($result); ?> </body> </html>
This will produce the following output
Array (  => John  => David  => Mike  => Sam )
- Java Program to Concatenate Two Arrays
- How to concatenate Two Arrays in C#?
- How to concatenate two arrays in java?
- The easiest way to insert date records in MySQL?
- Easiest way to sort an array in MongoDB
- How can I concatenate two arrays in java
- What is the easiest way to lose weight without exercise?
- What is the easiest way to store date in MySQL database?
- What is the easiest way to reverse a String in Java?
- What is the easiest way to convert int to string in C++
- What is the easiest way to transfer files from phone to PC?
- Easiest way to get number of rows in a MySQL table?
- What is the easiest way to convert a List to a Set in Java?