- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- Warning: Undefined array key 0 in /in/ZMr0p on line 7 Warning: Undefined array key 1 in /in/ZMr0p on line 7 2nd try: world hello
<?php
declare(strict_types=1);
$arr = ['one' => 'hello', 'two' => 'world' ];
[$hello, $world] = $arr;
echo "$hello $world\n";
echo "2nd try:\n";
['two' => $hello, 'one' => $world] = $arr;
echo "$hello $world\n";
// Hi!