In this example I have two possibilities to display, which car
is being hired
, where
and what fuel type
it has. If the car is chosen for different
weekday
, it comes this:
Ford, Philadelphia, Diesel
Toyota, Philadelphia, Diesel
Nissan, Philadelphia, Diesel, ,
If I choose One car for the whole week it comes only the one car:
Ford, Philadelphia, Diesel
Here is the code, I am using to display them:
} else {
$carnames = array();
foreach ($carname as $carraw) {
$hirestation = array();
if (!empty($carraw->name)) {
$hirestation[] = $carraw->name;
}
if (!empty($carraw->cartype)) {
$hirestation[] = $carraw->cartype;
}
if (!empty($carraw->address)) {
$hirestation[] = $carraw->carfuel;
}
$carname = implode(', ', $hirestation);
$dedupedroomnames[] = $roomname;
}
$carnames = implode('; ', $carnames);
$strcar = (!empty($allcarnames)) ? $carnames : $carnull;
}
The problem
is, that in case there were multiple
cars
for the week, at the end there are always this two comas
:
Ford, Philadelphia, Diesel, ,
After examing it, I found, that there comes the car
for the whole week
, if I choose it together
with the single choices
:
Ford, Philadelphia, Diesel, Dodge, D.C, Gas,
What I am missing within the code?