Click here to Skip to main content
15,884,237 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
Sergey Alexandrovich Kryukov 29-Jan-15 0:35am    
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[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 29-Jan-15 0:35am    
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;
 
Share this answer
 
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;
 
Share this answer
 

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