What is list in PHP?

Member

irwin

by irwin , in category: Technology , a month ago

What is list in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by sidney , a month ago

List is similar to an array but it is not a function, instead it is a language construct. This is used for assignment of a list of variables in one operation. If you are using PHP 5 version, then the list values start from a rightmost parameter, and if you are using PHP 7 version, then your list starts with a left-most parameter. Code is like:

1
2
3
4
5
<?php
$info = array('red', 'sign', 'danger');
// Listing all the variables
list($color, $symbol, $fear) = $info;
echo "$color is $symbol of $fear”;?php>