Skip to content

Commit 195543e

Browse files
committed
add associative array section
1 parent 661957d commit 195543e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

translations/es-AR.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,43 @@ $array = [...getArray(), 'baz'];
11671167
// $array = ['foo', 'bar', 'baz']
11681168
```
11691169

1170+
##### Matriz asociativa
1171+
1172+
![php-version-81](https://shields.io/badge/php->=8.1-blue)
1173+
1174+
Desde php 8.1, podés desempaquetar una matriz asociativa (con clave de cadena):
1175+
1176+
```php
1177+
$array1 = ['foo' => 'bar'];
1178+
$array2 = [
1179+
'baz' => 'qux',
1180+
...$array1
1181+
];
1182+
// $array2 = ['baz' => 'qux', 'foo' => 'bar',]
1183+
```
1184+
1185+
Podés desempaquetar la matriz con una clave ya existente:
1186+
1187+
```php
1188+
$array1 = ['foo' => 'bar'];
1189+
$array2 = [
1190+
'foo' => 'baz',
1191+
...$array1
1192+
];
1193+
// $array2 = ['foo' => 'bar',]
1194+
```
1195+
1196+
Podés desempaquetar una matriz vacía sin error ni advertencia:
1197+
1198+
```php
1199+
$array1 = [];
1200+
$array2 = [
1201+
...$array1,
1202+
...[]
1203+
];
1204+
// $array2 = []
1205+
```
1206+
11701207
### Argumentos Nombrados
11711208

11721209
![php-version-80](https://shields.io/badge/php->=8.0-blue)

0 commit comments

Comments
 (0)