I have a multidimensional array and I am trying to put comma delimiter and remove the last comma from each array so far I try this.

```
$cars=array("Volvo","BMW","Toyota","Honda","Mercedes");
$chunks =(array_chunk($cars,2));
foreach ($chunks as $key) {
    echo "<ul>";
    $data = array();
    foreach ($key as $value) {
        $data[] ="<li>".$value."</li>".",";
    }
    rtrim($data, ",");
    echo "</ul>";
}
foreach ($data as $key ) {
    echo $key;
}

```

Expected Output:

```
<ul>
    <li>Volvo,</li><li>BMW</li>
</ul>
<ul>
    <li>Toyota,</li><li>Honda</li>
</ul>
<ul>
    <li>Mercedes</li>
</ul>

```

Notice that there is no comma after `BMW`, `Honda`, or `Mercedes`.