LaravelHelpers
LaravelHelpers copied to clipboard
Arr::set Does not perform as expected.
When using Laravel's built in helper Illuminate\Support\Arr
, I run the following code:
use Illuminate\Support\Arr;
$a = [
"user.name" => "John Doe",
"user.email" => "[email protected]",
"user.address.street" => "123 Main St",
"user.address.city" => "Anytown"
];
$b = [];
foreach ($a as $key => $value) {
Arr::set($b, $key, $value);
}
When dumping $b
, I get the following:
[
"user" => [
"name" => "John Doe",
"email" => "[email protected]",
"address" => [
"street" => "123 Main St",
"city" => "Anytown",
],
],
]
This is the expected function. However, when I change the use statement to App\Helpers\Arr
I get the following:
[]