Having following array in my model:
$data = [
'route' => [
[
'id' => 1,
'departure_station' => 'Cluj-Napoca, Autogara',
'destination_station' => 'Bucuresti Nord',
'departure_date' => 'Joi, 18 Mar 2017. 20:45',
'arrival_date' => 'Vi, 19 Mar 2017. 02:15',
'price' => 150
],
[
'id' => 2,
'departure_station' => 'Budapest',
'destination_station' => 'London',
'departure_date' => 'Vin, 28 Mar 2017. 20:45',
'arrival_date' => 'Lu, 29 Mar 2017. 02:15',
'price' => 250
],
[
'id' => 3,
'departure_station' => 'Paris',
'destination_station' => 'Berlin',
'departure_date' => 'Joi, 18 Mar 2017. 20:45',
'arrival_date' => 'Vi, 19 Mar 2017. 02:15',
'price' => 450
],
]
];
I get it on my controller and it shows correctly when I do var_dump($data)
I try to send this multidimensional array in my view as following :
foreach($data as $key => $route)
{
foreach ($route as $element)
{
$id = $element['id'];
$departure_station = $element['departure_station'];
$destination_station = $element['destination_station'];
$departure_date = $element['departure_date'];
$arrival_date = $element['arrival_date'];
$price = $element['price'];
$i = count($route);
for($j=0; $j<=$i; $j++)
{
$html = $this->load->view("front/curse_interne.php", array(
'id' => $id,
'departure_station' => $departure_station,
'destination_station' => $destination_station,
'departure_date' => $departure_date,
'arrival_date' => $arrival_date,
'price' => $price), true);
echo json_encode(array("status" => 1, "html" => $html));
}
}
}
And I receive this array in my view in this way:
<?php
$data = array('route'=>(array(array('id'=>$id, 'departure_station'=>$departure_station , 'destination_station'=>$destination_station, 'departure_date'=>$departure_date, 'arrival_date'=>$arrival_date, 'price'=>$price ))));
var_dump($data);
exit();
?>
All I get from this var_dump in view is just the first array:
array(1) {
["route"]=>
array(1) {
[0]=>
array(6) {
["id"]=>
int(1)
["departure_station"]=>
string(21) "Cluj-Napoca, Autogara"
["destination_station"]=>
string(14) "Bucuresti Nord"
["departure_date"]=>
string(23) "Joi, 18 Mar 2017. 20:45"
["arrival_date"]=>
string(22) "Vi, 19 Mar 2017. 02:15"
["price"]=>
int(150)
}
}
}
How can I get the entire array in my View? Thank you!