Delete Trailing Comma - (Did my research before asking this, trust me.)
Ok before you say anything, I've done my research for an hour now and no
techniques are working... proceeding to the question:
I am using a multidimensional array and trying to echo all car models of
one particular make within an array. I have the following code:
<?php
$cars=array("Dodge"=>array("Avenger","Challenger","Charger","Dart"),"Toyota"=>array("Highlander","Tundra","Corolla"),"Nissan"=>array("Sentra","Altima","Maxima"));
echo "Make: Toyota"; echo "<br><br>";
foreach($cars['Toyota'] as $x)
{
$cars['Toyota'] = rtrim($x, ',');
echo "$x, ";
}
?>
Clearly my most recent shot at this was using the rtrim function but that
didn't work for me. Also tried implode function to no success. May I have
some help here? Your time is much appreciated! Thanks.
No comments:
Post a Comment