There is foreach loop in php. You have to traverse the array.

foreach($array as value)
{
  echo $key." has the value". $value;
}

If you simply want to add commas between values, consider using implode

$string=implode(",",$array);
echo $string;
Answer from Shakti Singh on Stack Overflow
🌐
PHP
php.net › manual › en › function.list.php
PHP: list - Manual
As noted elsewhere, the list() operator can be written in array format: <?php [0=>$width,1=>$height,2=>$type,3=>$dimensions,'mime'=>$mime]=$data; ?> ... Setting it like <?php list($var1,$varN) = null ?> does _not_ raise an E_NOTICE (or other error) and afaics effectively equals an https://php.net/function.unset of $var1,$varN.
🌐
W3Schools
w3schools.com › php › func_array_list.asp
PHP list() Function
<?php $my_array = array("Dog","Cat","Horse"); list($a, $b, $c) = $my_array; echo "I have several animals, a $a, a $b and a $c."; ?> Try it Yourself »
🌐
Reddit
reddit.com › r/php › a deep guide to php list() and its shorthand - array destructuring
r/PHP on Reddit: A Deep Guide to PHP list() and its shorthand - Array Destructuring
May 2, 2019 - Next article, you can use [] instead of array()! Reddit: woah noway. ... Don't use list()! Shorthand is bad, readablilty is everything. Programmers spend 60 of their time reading code and 40% writing it, so shorthand that make things hard to read is doubly bad. ... I agree with you that the shorthand makes confusions. I have told about it in my article. However, what do you think about this example? <?php $people = [ [ 'name' => 'John', 'age' => 20 ], [ 'name' => 'Callum', 'age' => 17 ] ]; // the old way /* foreach ($people as $person) { echo $person['name']; echo $people['age']; } */ // new way foreach ($people as ['name' => $name, 'age' => $age]) { echo $name; echo $age; }
🌐
ZetCode
zetcode.com › php-array › list
PHP list() - Array Destructuring in PHP
It's a convenient way to destructure arrays in PHP. The list function assigns values from an array to variables in a single statement.
🌐
DEV Community
dev.to › jovialcore › unlock-the-power-of-list-practical-usecase-of-list-in-php-52i7
Unlock the power of list: Practical usecase of list() in php. - DEV Community
January 23, 2024 - So what is a List() ? List() is used to assign values to a list of variables at once or in a single operation.It provides a convenient way to extract values from an array and assign them to individual variables in one go.
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-list-function
PHP list() Function - GeeksforGeeks
July 11, 2025 - The list() function is an inbuilt function in PHP which is used to assign array values to multiple variables at a time. This function will only work on numerical arrays. When the array is assigned to multiple values, then the first element in ...
Find elsewhere
🌐
Codecademy
codecademy.com › learn › learn-php-arrays-and-loops › modules › learn-php-arrays › cheatsheet
Learn PHP: Arrays and Loops: Learn PHP Arrays Cheatsheet | Codecademy
In PHP, an ordered array is a data structure representing a list of ordered, stored data. The location of an element in the array is known as its index.
🌐
Medium
medium.com › @AlMahfuzKhan › array-vs-arraylist-in-php-understanding-resizable-arrays-b8665bdb361a
Array vs. ArrayList in PHP: Understanding Resizable Arrays | by Al Mahfuz | Medium
February 6, 2025 - When transitioning from Java to PHP, developers often wonder whether PHP has an equivalent of Java’s ArrayList. In Java, the primary difference between an Array and an ArrayList is that ArrayList is resizable, meaning it can grow dynamically, whereas an Array has a fixed size.
🌐
IONOS
ionos.com › digital guide › websites › web development › php arrays
How to use a PHP array - IONOS
October 28, 2024 - A PHP array can hold different types of data, such as numbers, strings, booleans and more. They organize these values in an ordered and hi­er­ar­chi­cal structure, serving a wide range of purposes. Arrays are valuable not only for basic tasks like storing lists of items but also for complex scenarios where data requires multi-di­men­sion­al or­ga­ni­za­tion.
🌐
W3Schools
w3schools.com › php › php_arrays_multidimensional.asp
PHP Multidimensional Arrays
PHP supports multidimensional arrays that are two, three, four, five, or more levels deep.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript | MDN
July 28, 2026 - The array's object properties and list of array elements are separate, and the array's traversal and mutation operations cannot be applied to these named properties.
🌐
AlphaCodingSkills
alphacodingskills.com › php › notes › php-array-list.php
PHP list() Function - AlphaCodingSkills
Returns the assigned array. The example below shows the usage of list() function. <?php $info = array("John", 25, "London"); //listing all the variables list($name, $age, $city) = $info; echo "$name is $age years old.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-arrays-in-php
PHP Array – How to Use Arrays in Your PHP Projects
October 8, 2024 - A numerical array is a type of array which can store strings, numbers, and objects. Here's an example of a numeric array: <?php // Numeric/ index arrays $cars = array('Mecedes Benz', 'Hilux', 'Highlander', 'Hummer', 'Limozien'); var_dump($cars); ?>
🌐
W3Schools
www-db.deis.unibo.it › courses › TW › DOCS › w3schools › php › func_array_list.asp.html
PHP list() Function
<?php $my_array = array("Dog","Cat","Horse"); list($a, $b, $c) = $my_array; echo "I have several animals, a $a, a $b and a $c."; ?> Run example »
🌐
Web Reference
webreference.com › php › basics › arrays
Intro to PHP Arrays
PHP supports three main types of arrays, each serving different purposes and use cases. Understanding when to use each type is crucial for writing efficient and maintainable code. Indexed arrays store a list of values, where each value is accessed using an integer index.