work_it_work Posted September 21, 2009 Share Posted September 21, 2009 here's the scenario: <?php $array = array($a,$b,$c,$d,$e,$f); // $a $b $c $d $e $f are variables passed from a submitted form $implode_array = (",",$array); print_r ($implode_array);?> will look like this: ,,,,,,,, if there is no values in the $a $b $c $d $e $f variables.... in case variable $b and $e have values the print_r ($implode_array) will look like this: ,b,,,e,, how can i get rid of the empty comma's ? to make it look like b,e nothing else ? all the array must be inserted in one mysq field ... waiting for suggestions thanks in advance! Link to comment https://forums.phpfreaks.com/topic/175053-solved-need-help-with-an-array-and-comma/ Share on other sites More sharing options...
.josh Posted September 21, 2009 Share Posted September 21, 2009 $implode_array = preg_replace('~,+~',',',trim($implode_array,',')); Link to comment https://forums.phpfreaks.com/topic/175053-solved-need-help-with-an-array-and-comma/#findComment-922607 Share on other sites More sharing options...
work_it_work Posted September 21, 2009 Author Share Posted September 21, 2009 thank you! thank you! thank you! tested, working!!! Link to comment https://forums.phpfreaks.com/topic/175053-solved-need-help-with-an-array-and-comma/#findComment-922611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.