php - How to echo array elements in laravel
786
I want to echo arry elemnts in view followings are my code (controller)
$next_d_dts= \DB::table('tb_billing_cycle')->select('next_due_bill_date')->where('customer_id',$row->customer_id)->get();
return view('invoice.view')->with('next_d_dts',$next_d_dts);
I can print it using print function, eg:
print_r($next_d_dts);
Output:
Array ( [0] => stdClass Object ( [next_due_bill_date] => 2019-03-28 ) [1] => stdClass Object ( [next_due_bill_date] => 2020-02-28 ) )
Answer
Solution:
You need to iterate over the collection of objects:
If you just want to see its contents but not stop the script:
You've also asked how to iterate without Blade:
Answer
Solution:
Answer
Solution:
you should used foreach loop in laravel like this
for more information read Laravel Manual blade template
Also you can used
dd($next_d_dts) //The dd function dumps the given variables and ends execution of the script
Answer
Solution:
You can convert it into array using
toArray()
and iterate over itIn view
Or
print_r($next_d_dts)
Answer
Solution:
Simple.
Answer
Solution:
you need to use Blade Loops syntax invoice.view.blade.php