I am new to Laravel and trying to pass a one dimensional array from controller to the view.
This is my controller function
public function onedim_array()
{
$info = array(
'firstname' => 'John',
'lastname' => 'Cena',
'from' => 'USA'
);
return view('one_dim_array', compact('info'));
}
This is my view file:
<?php
foreach($info as $i)
{
echo $i['firstname'];
}
?>
It gives me the following error:
ErrorException in 34a7177cfbceee0b4760125499bdaca34b567c0b.php line 5: Illegal string offset 'firstname' (View: C:\AppServ\www\blog4\resources\views\one_dim_array.blade.php)
I don't know where I am making mistake. Please Help