Form this array, how can I remove the first element of Provinces ?
Array
(
[Country] => Canada
[Provinces] => Array
(
[0] => Quebec
[1] => Ontario
[2] => British Columbia
)
)
Thanks.
If you want to remove the first items in the array for the key name Provinces and the numerical keys do not have to be preserved, you could also use array_splice:
$arr = [
"Country" => "Canada",
"Provinces" => [
"Quebec",
"Ontario",
"British Columbia"
]
];
array_splice($arr["Provinces"], 0, 1);
Php demo
Or using unset to keep the numerical keys:
unset($arr['Provinces'][0]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With