Click here to Skip to main content
14,930,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In view it is comig like
Bar,Children's Play Area,Conference & Banquet Facilitiy,
Here i want to remove comma after Conference & Banquet Facilitiy.where comma is not required.How can i do it.Suggest me
Below is the coding

PHP
$mulcheck=$form['Venue']['facility'];

                  $mulcheck1=explode(",",$mulcheck);


           for($i=0;$i<count($mulcheck1);$i++)
           {
           echo $getfacility1[$i]['Facility']['facility'].',';

            }
Posted
Comments
   
Isn't it PHP? Is so, why all other question tags?
Anyway, how about this: wouldn't it better to avoid extra comma in first place?
—SA

Try this:
<?php
echo(rtrim("abcdef,", ","));
?>

Read more: rtrim[^]
   
Comments
   
5ed, but I would also suggest to think about not adding unwanted extra comma in first place.
—SA
Peter Leow 29-Jan-15 1:10am
   
Agreed, it should be avoided in the first place. Thank you. Sergey.
Sradhanjali Behera 30-Jan-15 8:36am
   
it is present in a for loop .its not working @Peter Leow
Got the solution.works fine
PHP
$mulcheck=$form['Venue']['facility'];
                 $mulcheck1=explode(",",$mulcheck);
                 $data1='';
                 for($i=0;$i<count($mulcheck1);$i++)>
                   {
                   $data1.= $getfacility1[$i]['Facility']['facility'].',';
                   }
                   $data = substr(trim($data1), 0, -1);
                   echo $data;
   
Got the solution.works fine
PHP
$mulcheck=$form['Venue']['facility'];
			 	  $mulcheck1=explode(",",$mulcheck);
				  $data1='';
	 	 	      for($i=0;$i<count($mulcheck1);$i++)>
					{
					$data1.= $getfacility1[$i]['Facility']['facility'].',';
					}
					$data = substr(trim($data1), 0, -1);
					echo $data;
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900