-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Description
Description
The following code:
<?php
$arr = ['y' => []];
array_unshift($arr['x'], 'a', 'b');
print_r($arr);
Resulted in this output:
Uncaught TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given
But I expected this output instead:
Array
(
[x] => Array
(
[0] => a
[1] => b
)
)
I would expect php to accept reference to null
for array_unshift
(and friend functions) and create empty array like $arr['x'][] = 'a'
syntax does.