note 71257 added to function.trim

From: Date: Sun, 19 Nov 2006 20:40:35 +0000
Subject: note 71257 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-119875@lists.php.net to get a copy of this message
If you need to trim a string from the beginning and end of a string, then this function maybe prove handy. <?php function lrclean($str,$rm) { $i = strlen($rm); do { if (substr($str,0,$i) == $rm) {$str = substr($str,$i);} } while (substr($str,0,$i) == $rm); do { if (substr($str,-$i,$i) == $rm) {$str = substr($str,0,-$i);} } while (substr($str,-$i,$i) == $rm); return $str; } // prints 'text' echo lrclean('xyztextxyz','xyz'); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 69.35.76.144 ---- Manual Page -- http://www.php.net/manual/en/function.trim.php Edit -- https://master.php.net/note/edit/71257 Del: integrated -- https://master.php.net/note/delete/71257/integrated Del: useless -- https://master.php.net/note/delete/71257/useless Del: bad code -- https://master.php.net/note/delete/71257/bad+code Del: spam -- https://master.php.net/note/delete/71257/spam Del: non-english -- https://master.php.net/note/delete/71257/non-english Del: in docs -- https://master.php.net/note/delete/71257/in+docs Del: other reasons-- https://master.php.net/note/delete/71257 Reject -- https://master.php.net/note/reject/71257 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119875) next »