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 Link to comment https://forums.phpfreaks.com/topic/70160-removing-value-from-echo/ Share on other sites More sharing options...
Jessica Posted September 21, 2007 Share Posted September 21, 2007 http://php.net/explode will help. Link to comment https://forums.phpfreaks.com/topic/70160-removing-value-from-echo/#findComment-352350 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? Link to comment https://forums.phpfreaks.com/topic/70160-removing-value-from-echo/#findComment-352388 Share on other sites More sharing options...
MmmVomit Posted September 21, 2007 Share Posted September 21, 2007 $result = explode(",", $total); Link to comment https://forums.phpfreaks.com/topic/70160-removing-value-from-echo/#findComment-352401 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 Link to comment https://forums.phpfreaks.com/topic/70160-removing-value-from-echo/#findComment-352406 Share on other sites More sharing options...
Jessica Posted September 21, 2007 Share Posted September 21, 2007 substr and strlen Link to comment https://forums.phpfreaks.com/topic/70160-removing-value-from-echo/#findComment-352410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.