phplaraveldumpdd

Laravel foreach loop only shows first entry with dd()


It might be a weird question but I need your help

I might have an array with values.

foreach ($users as $user)
{
    $name_user = //condition
    array_push($firstarray, $name_user );
}

Let's suppose that $firstarray has these values now ( example : 1 ,2 ,3)

Now

foreach ($firstarray as $t)
{
    dd($t);       
}

It shows me only the first value

Should it work like this ? I think it has to show the three values.


Solution

  • Of course it will only display 1 because dd() means Dump and Die

    You're using DD in a loop, during the first loop, you used the dd(), after reading the dd(), it will kill all the next processes

    I suggest you use the dump() so you could see all the contents