I have a loop that looks like this
$folder = [];
$explode = explode("/", $product->folder);
for($i = 0; $i < count($explode); $++)
{
$folder[$i] = 'test'
}
dd($folder);
what I'm trying to do here is to create a nested array depending on how many folders there are based on what I get from $explode.
So ideally what I want is this
[
"folder1" => [
"folder2" => "test"
]
]
and it would carry on being nested, so if my $product->folder looks like this cat1/cat2/cat3 then the array would looks like this
[
"cat1" => [
"cat2" => [
"cat3" => "product"
]
]
]