Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

remove comma from last item of loop php

$animels = array("Dog", "Cat", "Tiger", "Lion", "Cow");

$count_animel = count($animels);
$set_count = 0;

foreach ($animels as $animel) {
    echo $animel;
    $set_count = $set_count + 1;
    if ($set_count < $count_animel) {
      echo ", ";
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #comma #item #loop #php
ADD COMMENT
Topic
Name
7+1 =