Hi

Am 2026-07-02 05:51, schrieb Seifeddine Gmati:
`array_destruct()` that would address the readability argument (which is
hard to discuss away because it is hyper subjective).

This can't work, and not for stylistic reasons. Destructuring happens
in a *write* context: the construct sits on the left of `=` and
receives bindings. A function can't do that. `array_destruct($a, $b) =
$arr` isn't expressible

That specific syntax would indeed not be possible, but the following would work:

    <?php

    function destruct(array $a, &...$results) {
        foreach ($results as $key => &$val) {
            $val = $a[$key];
        }
    }

    destruct([1, 2, 3, 'b' => 'b'], $a, b: $b);
    var_dump($a, $b);

see: https://3v4l.org/ia489n#veol

Best regards
Tim Düsterhus

Reply via email to