directonpc
php remove last comma from a loop list
(Oct 29 2014 at 09:09am)
I am taking out time to share a simple trick to remove comma "," from the end of a list for example:
days of the week: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, to remove the last comma and make your work look more professional use this method.
code:
$data = mysql_query("SELECT weeks FROM date_table") ;
$i = 0;
while ($days = mysql_fetch_array($data) {
$myDays = $days['weeks'];
if ($i > 0) {
echo "," ;
}
$i++
echo $myDays;
}
this code will display days of the week without last comma
The if statement ensures that no comma is displayed before the first time.
[2K views]
Last edited 23 Jan 2017
You may also Like:
dice5t
Re- php remove last comma from a loop list
(Oct 29 2014 at 10:14am)
hahahaahahahahah . Great. :-p
quote |
like (0)