PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How can I remove spaces from around a string value?


If you want to do this, then the function you need is trim. It is very simple and works like this:

<?php
$toomuchspace 
"    how are you    ";
echo 
"<$toomuchspace>\n";
$thatsbetter trim($toomuchspace);
echo 
"<$thatsbetter>";
?>


And this is the result:

< how are you >

Comments on this Question/Answer

How can I remove spaces from between a string value? for example : "what's going on, my name is vishwas"; like show : "what's going on, my name is vishwas";
By: vishwas, 15 Jan 2009 22:23:12



Reply to comments / post your own comment >>>

ASK A QUESTION

More strings PHP Questions

How do I remove trailing whitespace from a string?

What is the difference between print and echo?

How do I check if a string contains HTML?

How do I make the first letter of a string uppercase?

How do I remove space from the start of a PHP string?



Custom Search