How to assign multiple values to multiple variables in one line with PHP

2 Answers

0 votes
list($a, $b, $c, $d) = [1, 2, 3, 4];

echo "$a, $b, $c, $d"; 



/*
run:

1, 2, 3, 4

*/

 



answered Jul 14, 2025 by avibootz
0 votes
[$a, $b, $c, $d] = [1, 2, 3, 4];

echo "$a, $b, $c, $d"; 



/*
run:

1, 2, 3, 4

*/

 



answered Jul 14, 2025 by avibootz
...