jmr3460 Posted October 30, 2009 Share Posted October 30, 2009 I have created a string from an array. I have inserted commas from my form values. I am trying to remove the last comma from the string and can't seem to remove it. I have tried chop, rtrim, substr, substr_remove, trim and none of them seem to remove the last comma. $sql_meeting2 = "SELECT * FROM meeting WHERE location_id = '$location_id' ORDER BY day_id"; $result_meeting2 = mysql_query($sql_meeting2) or die(mysql_error()); while($data_meeting2 = mysql_fetch_array($result_meeting2)){ $day = $data_meeting2['day']; $times = $data_meeting2['time']; $open = $data_meeting2['open']; $format = $data_meeting2['format']; $format is the string I am trying to rtrim from. This is my form code <td style="padding-left:15px;"> <input type="checkbox" name="format[]" value="Discussion,">Discussion<br /> <input type="checkbox" name="format[]" value="Basic Text Study,">Basic Text Study<br /> <input type="checkbox" name="format[]" value="It Works Study,">It Works Study<br /> <input type="checkbox" name="format[]" value="IP Study,">IP Study<br /> <input type="checkbox" name="format[]" value="Topic,">Topic<br /> <input type="checkbox" name="format[]" value="Candlelight,">Candlelight<br /> <input type="checkbox" name="format[]" value="Speaker,">Speaker<br /> <input type="checkbox" name="format[]" value="Birthday,">Birthday<br /> <input type="checkbox" name="format[]" value="Men,">Men<br /> <input type="checkbox" name="format[]" value="Women,">Women<br /> <input type="checkbox" name="format[]" value="Varies,">Varies<br /> <input type="checkbox" name="format[]" value="Other">Other </td></tr> I have manipulated this form information with this: $formats = $_POST['format']; $format = implode(' ',$formats); Can anyone help? Thanks Link to comment https://forums.phpfreaks.com/topic/179587-solved-last-character-removed/ Share on other sites More sharing options...
Mchl Posted October 30, 2009 Share Posted October 30, 2009 $strin = substr($string,0,-1); Link to comment https://forums.phpfreaks.com/topic/179587-solved-last-character-removed/#findComment-947666 Share on other sites More sharing options...
jmr3460 Posted October 30, 2009 Author Share Posted October 30, 2009 Thank you very much. That did the trick. Link to comment https://forums.phpfreaks.com/topic/179587-solved-last-character-removed/#findComment-948063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.