Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

itsjamalkhan's avatar

how to print 2d array in laravel 5.4.12 by dd();?

please help me to solve this problem that how to die and dump 2D array in laravel.. i tried this but not working $arr=collect($request->input('title['+$i+']')); dd($arr->count());

also tried this code

$arr=collect($request->input('title[0]')); dd($arr->count());

0 likes
5 replies
SaeedPrez's avatar
dd(
    // All these do the same thing
    $request->title,
    $request['title'],
    $request->input('title'),
    $request->get('title'),
    // I love the global helper
    request('title'),

    // count items in the array
    count(request('title'))
);
1 like
SaeedPrez's avatar
Level 50

count(request('title')[key]) where key is the index, it can be 0, 1, etc or a word like name or age..

count(request('title')[0])
count(request('title')['age'])
1 like

Please or to participate in this conversation.