Re: [PHP] strip white space
Steve Buehler wrote: Another question is this. The "&" in wsstrip(&$str). Does that mean that it takes the input to the function as Global and changes it Globally? I am assuming that because that is what the whole function seems to do for me. No, it means that it passes a reference to the variable rather than the value. In other words, any changes made to the variable in the function will change the variable passed in too. See http://us2.php.net/references -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strip white space
Figures, right after I emailed this, I found it after looking for over an hour. Here is the result and some people had emailed me parts of this: $team_name=" BV Stars Black"; wsstrip($team_name); function wsstrip(&$str) { $str=ereg_replace (' +', ' ', trim($str)); $str=ereg_replace("[\r\t\n]","",$str); } echo $team_name; // Would produce the following line BV Stars Black Thank you all for helping on this. I found the answer by "David Gillies" at: http://us4.php.net/trim Another question is this. The "&" in wsstrip(&$str). Does that mean that it takes the input to the function as Global and changes it Globally? I am assuming that because that is what the whole function seems to do for me. Thanks again everybody Steve At 11:49 AM 7/2/2003 -0500, you wrote: I am not sure how to go about this and hope that someone can help here. I have a variable like the following: $team_name="BV Stars Black"; it has two spaces between the words Stars and Black. What I am trying to do is to take this variable, check for and strip the following: 1. Leading spaces 2. Ending spaces 3. Double (or more) spaces in the variable leaving only one space between words. Does php have any built in function that I can not find that will do this? Thank You in Advance Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by the MailScanner at ow4, and is believed to be clean. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] strip white space
would $team_name = trim(ereg_replace( " +", " ", $team_name )); do it? -Original Message- From: Steve Buehler [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 02, 2003 9:50 AM To: PHP Subject: [PHP] strip white space I am not sure how to go about this and hope that someone can help here. I have a variable like the following: $team_name="BV Stars Black"; it has two spaces between the words Stars and Black. What I am trying to do is to take this variable, check for and strip the following: 1. Leading spaces 2. Ending spaces 3. Double (or more) spaces in the variable leaving only one space between words. Does php have any built in function that I can not find that will do this? Thank You in Advance Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php