note 112577 added to function.rtrim

From: Date: Mon, 01 Jul 2013 09:11:00 +0000
Subject: note 112577 added to function.rtrim
Groups: php.notes 
Request: Send a blank email to php-notes+get-195420@lists.php.net to get a copy of this message
On the recurring subject of string-stripping instead of character-stripping rtrim() implementations... the simplest (with a caveat) is probably the basename() function. It has a second parameter that functions as a right-trim using whole strings: <?php echo basename('MooFoo', 'Foo'); ?> ...outputs 'Moo'. Since it also strips anything that looks like a directory, it's not quite identical with hacking a string off the end: <?php echo basename('Zoo/MooFoo', 'Foo'); ?> ...still outputs 'Moo'. But sometimes it gets the job done. ---- Server IP: 87.106.1.137 Probable Submitter: 212.79.14.14 ---- Manual Page -- http://php.net/manual/en/function.rtrim.php Edit -- https://master.php.net/note/edit/112577 Del: integrated -- https://master.php.net/note/delete/112577/integrated Del: useless -- https://master.php.net/note/delete/112577/useless Del: bad code -- https://master.php.net/note/delete/112577/bad+code Del: spam -- https://master.php.net/note/delete/112577/spam Del: non-english -- https://master.php.net/note/delete/112577/non-english Del: in docs -- https://master.php.net/note/delete/112577/in+docs Del: other reasons-- https://master.php.net/note/delete/112577 Reject -- https://master.php.net/note/reject/112577 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195420) next »