note 87947 added to function.trim

From: Date: Thu, 01 Jan 2009 15:24:38 +0000
Subject: note 87947 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-148740@lists.php.net to get a copy of this message
there is a mistake in "josecruz at josecruz dot com dot br" function: it deletes the first char after spaces (because of while). here is the correct function: <?php function TrimStr($str) { $str = trim($str); for($i=0;$i < strlen($str);$i++) { if(substr($str, $i, 1) != " ") { $ret_str .= trim(substr($str, $i, 1)); } else { while(substr($str,$i,1) == " ") { $i++; } $ret_str.= " "; $i--; // *** } } return $ret_str; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 85.107.132.251 ---- Manual Page -- http://www.php.net/manual/en/function.trim.php Edit -- https://master.php.net/note/edit/87947 Del: integrated -- https://master.php.net/note/delete/87947/integrated Del: useless -- https://master.php.net/note/delete/87947/useless Del: bad code -- https://master.php.net/note/delete/87947/bad+code Del: spam -- https://master.php.net/note/delete/87947/spam Del: non-english -- https://master.php.net/note/delete/87947/non-english Del: in docs -- https://master.php.net/note/delete/87947/in+docs Del: other reasons-- https://master.php.net/note/delete/87947 Reject -- https://master.php.net/note/reject/87947 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148740) next »