★ wanayoo — archive 1999 http://www.php.net/manual/function.trim.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Strings
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Strings
* AddCSlashes
* AddSlashes
* bin2hex
* Chop
* Chr
* chunk_split
* convert_cyr_string
* count_chars
* crc32
* crypt
* echo
* explode
* flush
* get_html_translation_table
* get_meta_tags
* hebrev
* hebrevc
* htmlentities
* htmlspecialchars
* implode
* join
* levenshtein
* ltrim
* md5
* Metaphone
* nl2br
* ob_start
* ob_get_contents
* ob_end_flush
* ob_end_clean
* ob_implicit_flush
* Ord
* parse_str
* print
* printf
* quoted_printable_decode
* quotemeta
* rtrim
* sscanf
* setlocale
* similar_text
* soundex
* sprintf
* strcasecmp
* strchr
* strcmp
* strcspn
* strip_tags
* stripcslashes
* stripslashes
* stristr
* strlen
* str_pad
* strpos
* strrchr
* str_repeat
* strrev
* strrpos
* strspn
* strstr
* strtok
* strtolower
* strtoupper
* str_replace
* strtr
* substr
* substr_count
* substr_replace
* trim
* ucfirst
* ucwords
Manual: trim
View the source code for this pageSearch the site



Previous page
 substr_replace
 Updated
Sat, 12 Aug 2000
ucfirst 
Next page


trim

(PHP3 , PHP4 )

trim --  Strip whitespace from the beginning and end of a string

Description

string trim (string str)

This function strips whitespace from the start and the end of a string and returns the stripped string. The whitespace characters it currently strips are: "\n", "\r", "\t", "\v", "\0", and a plain space.

See also chop() and ltrim().


User Contributed Notes: trim


brez@jordanchans.com
05-Jan-2000 11:40
It trims ALL leading and trailing spaces, one solution to the problem with explode()include spaces in the
array.



lars@xenux.dk
24-Jan-2000 11:57
If you have a string which only contains whitespace, then this function cannot strip the whitespace.


martin@coretrek.com
01-Jul-2000 09:38
how do strip whitespaces in the middle of a string, for instance if a user adds a space between his regin prefix and the rest of his phonenumber?
-martin



webmaster@nnytech.net
06-Jul-2000 12:45
An example

<?php
$stri = "\nThis string has \ whitespace\n\n\n";
echo trim($stri);
?>

Hope that helps..



alivesay@yellowbrix.com
24-Jul-2000 06:35
If you are trying to take out whitespace from the middle of a string, you need to use a different function, str_replace:

<PRE>str_replace(" ", "", "United Kingdom);</PRE>



 About Notes


Previous page
 substr_replace
 Updated
Sat, 12 Aug 2000
ucfirst 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.