In this tutorial, We will learn how to dot() function. The Arr::dot method flattens a multi-dimensional array in a single level array 


Example:

Create HomeController and put the following code 


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\FileController;
use Illuminate\Support\Arr;

class HomeController extends Controller
{
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        $array1 =  ['products' => ['toys' => ['price' => 100]]];

        $doted1 = Arr::dot($array1);
        print_r($doted1);
        //['products.toys.price' => 100]

        $array2 = ['technologies' => ['laptop' => 'Dell']];

        $doted2 = Arr::dot($array2);
        print_r($doted2);
        //['technologies.laptop' => 'dell']
    }
}


Output:

['products.toys.price' => 100]
['technologies.laptop' => 'dell']

Thanks, May this example will help you.