Core PHP, How To

How to Print Multiple Array Values in PHP?

Written by Bikash · 54 sec read >

To print multiple array values in PHP, first, we have to merge multiple arrays and store them in a variable.

To merge two arrays we use array_merge() function. Here on this task we check two types of multiple arrays and merge those to print the complete value.

  1. Example with indexed arrays.
  2. And with associative arrays.

Example With Indexed Arrays

Here we define two different arrays, to get the combined result we first merge both arrays by using the PHP array_merge() function.

After that, we loop through the combined array variable to get complete data.

Also Read: Bootstrap Datepicker- Complete Solution to Integrate


Print Multiple Array Value in PHP
Multiple Indexed Array Values at Once

Also Read: CSS background-image Properties

Example With Associative Arrays

In the below example, we define two associative arrays and combine them by using the same PHP function. After that, we loop through the array to print all values.

And then we print a complete array with their keys and values.


Print Multiple Array Value in PHP
Multiple Associative Array Values at Once


The above source code is the complete explanation of How we can print multiple array values in PHP at once by merging the arrays.

To merge both types of arrays indexed and associative we use PHP inbuilt function array_merge().

You can consider the complete program as a PHP array merge with an example.

Please let me know if you are facing any issues with the implementation.

Also Read: XAMPP, Apache – Error: Apache shutdown unexpectedly

Happy Coding..!

Was this article helpful?
Written by Bikash
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP. Profile

Leave a Reply

Your email address will not be published. Required fields are marked *