note 77010 added to function.trim

From: Date: Fri, 10 Aug 2007 05:49:59 +0000
Subject: note 77010 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-129390@lists.php.net to get a copy of this message
Robin Leffman's code could be improved further... <?php $string = 'This string has no whitespaces.'; echo str_replace(' ', '', $string ); ?> Of course, like Leffman's code, that only removes space characters, not necessarily all whitespace (or characters in some arbitrary $whiteSpace string). For that <?php function trimlrm ($hayStack, $whiteSpaceChars) { $char = $whiteSpaceChars[0]; $chars = str_repeat($char, strlen($whiteSpaceChars); $trimmed = strtr($hayStack, $whiteSpaceChars, $chars))); return str_replace($char, '', $trimmed); } ?> would probably work, but like the others, fails to give '..' the same specialness that it has in trim(). ---- Server IP: 202.89.58.1 Probable Submitter: 60.234.168.92 ---- Manual Page -- http://www.php.net/manual/en/function.trim.php Edit -- https://master.php.net/note/edit/77010 Del: integrated -- https://master.php.net/note/delete/77010/integrated Del: useless -- https://master.php.net/note/delete/77010/useless Del: bad code -- https://master.php.net/note/delete/77010/bad+code Del: spam -- https://master.php.net/note/delete/77010/spam Del: non-english -- https://master.php.net/note/delete/77010/non-english Del: in docs -- https://master.php.net/note/delete/77010/in+docs Del: other reasons-- https://master.php.net/note/delete/77010 Reject -- https://master.php.net/note/reject/77010 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129390) next »