Example 1 — Split an Array into Variables
list() copies each value into its own variable, in the same order as the array.
<?php
$point = [10, 20];
list($x, $y) = $point;
echo "x = ", $x, ", y = ", $y, PHP_EOL; How It Works
- $point is a list with two values.
- list($x, $y) matches the first variable with key 0 and the second with key 1.
- So $x becomes 10 and $y becomes 20.
- echo prints both variables.

