En Perl, je pourrais attribuer une liste à plusieurs valeurs dans un hachage, comme ceci:affectation à une tranche de tableau associatif en php
# define the hash...
my %hash = (
foo => 1,
bar => 2,
baz => 3,
);
# change foo, bar, and baz to 4, 5, and 6 respectively
@hash{ 'foo', 'bar', 'baz' } = (4, 5, 6);
Est-il possible de faire la même chose en php? En fait, y a-t-il même un moyen d'obtenir une tranche d'un tableau d'assoc?
Note: Je connaissais déjà la liste et le but de la question était de trouver une solution plus élégante que la suivante: list ($ array ['a'], $ array ['b'], $ array [' c '], $ tableau [' d '], $ tableau [' e '], $ tableau [' f '], $ tableau [' g '], $ tableau [' h '], $ tableau [' i ' ], $ tableau ['j'], $ tableau ['k'], $ tableau ['l'], $ tableau ['m']) = some_function(); – spudly