LaravelHelpers icon indicating copy to clipboard operation
LaravelHelpers copied to clipboard

Arr::set Does not perform as expected.

Open NathanLochala opened this issue 6 months ago • 0 comments

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:

[]

NathanLochala avatar Aug 06 '24 13:08 NathanLochala