note 73984 added to function.trim

From: Date: Mon, 19 Mar 2007 22:36:00 +0000
Subject: note 73984 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-124604@lists.php.net to get a copy of this message
trim's code can of course be simplified with some use of the trim() function.... <?php $str = " Words with lots of spaces "; $str = preg_replace('/\s\s+/', ' ', trim($str)); ?> Doing the trim() first reduces the workload being put on the more expensive preg_replace(). ---- Server IP: 203.89.181.184 Probable Submitter: 60.234.168.92 ---- Manual Page -- http://www.php.net/manual/en/function.trim.php Edit -- https://master.php.net/note/edit/73984 Del: integrated -- https://master.php.net/note/delete/73984/integrated Del: useless -- https://master.php.net/note/delete/73984/useless Del: bad code -- https://master.php.net/note/delete/73984/bad+code Del: spam -- https://master.php.net/note/delete/73984/spam Del: non-english -- https://master.php.net/note/delete/73984/non-english Del: in docs -- https://master.php.net/note/delete/73984/in+docs Del: other reasons-- https://master.php.net/note/delete/73984 Reject -- https://master.php.net/note/reject/73984 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124604) next »