PHP List Check Case ()

When reading the list () function, you can find such a warning in the notes section:

A warning

list () assigns values โ€‹โ€‹starting with the rightmost parameter. If you use simple variables, you do not need to worry about that. But if you use arrays with indexes, you usually expect the order of indexes in the array to be the same as you wrote in list () from left to right; which is not. It is assigned in reverse order.

Can someone provide some sample code when the reverse order distribution happens?

+4
source share
1 answer
php> $array = array(); php> list($array[0], $array[1]) = array(1, 2) php> var_dump($array) array(2) { [1] => int(2) [0] => int(1) } 

So, [1] is assigned to [0].

+4
source

Source: https://habr.com/ru/post/1479561/


All Articles