Hi All,
I'm sure there is an easy solution for this but I am unable to find it.
I am new to PHP and after a little help...
the via data is stored in a database in this format... |51.105166,-1.695971|51.011055,-2.1068|50.945233,-2.617664||||
I'm trying to find a way of loosing the last comma if there are 1 or more entries, any ideas guys.
What I'm getting is :
var points = [{location: '51.105166,-1.695971'},{location: '51.105166,-1.695971'},];
What I'm after is:
var points = [{location: '51.105166,-1.695971'},{location: '51.105166,-1.695971'}];
<?php
if($via != null){
echo "var points = [";
foreach($via as $point){
if($point != ""){
echo "{location:";
echo " '".$point."'";
echo "},";
}
}
echo "];\n";
}
?>