Laravel Arr get() function Example

In this example, I explain how to use laravel Arr get() function. Laravel arr get() function to you can get array element value. The Arr::get method retrieves a value from a deeply nested array using “dot” notation.

Example : Laravel array get() function


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Support\Arr;

class UserController extends Controller
    public function index(){        
        $array = ['products' => ['desk' => ['price' => 445]]];

        $price = Arr::get($array, 'products.desk.price');


        $array1 = ['car' => ['bmw' => ['no' =>'ks-999',],'honda' => ['no' =>'cs-888',]]];

        $price1 = Arr::get($array, '');




use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;

Route::get('users', [UserController::class,'index']);

I hope you understand laravel arr get function and it can help you…

Read Also :  Laravel Livewire Click Event Example