note 75744 deleted from function.trim by felipe

From: Date: Wed, 06 Aug 2008 22:07:00 +0000
Subject: note 75744 deleted from function.trim by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143250@lists.php.net to get a copy of this message
Note Submitter: jayoungh5 at yahoo dot com ---- I needed to trim whitespace on the left, on the right, in the middle, everywhere. Here's a function to do it. The first parameter ($hayStack) will have all the characters found in the second parameter ($whiteSpaceChars) removed from it. function trimlrm ($hayStack, $whiteSpaceChars) { $trimmmed = ""; for ($i = 0; $i < strlen($hayStack); $i++) { if (strpos($whiteSpaceChars,$hayStack[$i]) === false) $trimmed .= $hayStack[$i]; } return $trimmed; }

« previous php.notes (#143250) next »