Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- PHPWind-- A PHP forum script applcaition in China
- How to blend adsense inside your post?
- Formatting my post
- Notepad++ - Add C++ compiler
- Install PHPMailer 5.2.4 and use smtp gmail
- Set up a child account and set screen time limit in Windows 8
- Wayback Machine - see archived versions of web pages across time
- phpexcel toggle expand and hide column in EXCEL and summary
- Install PHP ibm_db2 extension in Linux (redHat)
- PHP: add a download as pdf file button in report page
Friday, October 18, 2013
Remove last character of a string, for example comma and a space
In the following example, I combined all reviewer full name using ', ' (comma and a pace), but I need to remove the last comma and space when they are displayed. PHP function rtrim can be used for this purpose, example PHP code:
$sql_1 = "SELECT
M.prefix,M.first_name,M.last_name
FROM cesei_module_user_reviews MUR
LEFT JOIN cesei_members M ON MUR.member_id=M.member_id WHERE MUR.module_id=".$module_id ;
$result_1 = mysql_query($sql_1, $db);
$reviewers = ' ';
while($row_1 = mysql_fetch_assoc($result_1)){
$reviewers .= trim(htmlspecialchars($row_1['prefix'].' '.$row_1['first_name'].' '.$row_1['last_name'])).', ';
}
$reviewers = rtrim($reviewers, ", ");
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment