Andrew R Posted September 21, 2007 Share Posted September 21, 2007 Sorry for the badly described topic, don't know how else to explain it For example. If had the following coordinates in the database: -5.717979 54.728432,-5.672246 54.757900,-5.621388 54.786976, If I then echo them how would I remove the , (comma) at the end? As I will echoing multiple coordinates from the database, some longer than others I can't simply remove the comma after a certin about numbers. Any help would be appreciated. Cheers Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 21, 2007 Share Posted September 21, 2007 http://php.net/explode will help. Quote Link to comment Share on other sites More sharing options...
Andrew R Posted September 21, 2007 Author Share Posted September 21, 2007 Thanks Tryed this, doesn't seem to work though: <?php $total = "-5.717979 54.728432,-5.672246 54.757900,-5.621388 54.786976,-5.564545 54.816902,-5.502621 54.848289,-5.436880 54.881577,-5.370000 54.915535,-5.302828 54.949612,-5.234945 54.984013,-5.166701 55.018578,"; $result = explode("$total,", $total); echo $result[0]; php?> It should select all values excluding the last comma? Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted September 21, 2007 Share Posted September 21, 2007 $result = explode(",", $total); Quote Link to comment Share on other sites More sharing options...
Andrew R Posted September 21, 2007 Author Share Posted September 21, 2007 Thanks very much The thing is I only need to remove the very last comma. So basically I want to select everything before the very last comma. Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 21, 2007 Share Posted September 21, 2007 substr and strlen Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.