note 65815 added to function.rtrim

From: Date: Mon, 08 May 2006 13:01:55 +0000
Subject: note 65815 added to function.rtrim
Groups: php.notes 
Request: Send a blank email to php-notes+get-110853@lists.php.net to get a copy of this message
To remove an unwanted character - example "." - if exist or not. The example above doesn't include the case where there is no "." If there is not "." at the example above the last word will be deleted. Have fun with this code. <?php $text = "This string contains. some unwanted characters on the end ."; $text = trim($text); $last = $text{strlen($text)-1}; if (!strcmp($last,".")) { $text = rtrim($text, 'a..z'); $text = rtrim($text, '.'); } ?> ---- Server IP: 192.117.122.43 Probable Submitter: 88.154.197.55 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.rtrim.php Edit -- http://master.php.net/note/edit/65815 Del: integrated -- http://master.php.net/note/delete/65815/integrated Del: useless -- http://master.php.net/note/delete/65815/useless Del: bad code -- http://master.php.net/note/delete/65815/bad+code Del: spam -- http://master.php.net/note/delete/65815/spam Del: non-english -- http://master.php.net/note/delete/65815/non-english Del: in docs -- http://master.php.net/note/delete/65815/in+docs Del: other reasons-- http://master.php.net/note/delete/65815 Reject -- http://master.php.net/note/reject/65815 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#110853) next »