Quick Search:
 
 PHP Code: Remove Extra Spaces From A String Jump to:  
Category: >> PHP Code >> Remove Extra Spaces From A String  

<< lastnext >>

Snippet Name: Remove Extra Spaces From A String

Description: Three ways to remove extra spaces from string and replace them with "+" symbols (handy for use in creating a "GET" string, such as for a search form).

Also see:
» Dynamically add and remove elements
» Neatly trim a string to a set number o...
» Search array elements for a substring
» Add a period at the end of a string if...
» Count capital letters in a string
» Search All Words Of A String In mySQL
» Remove Extra Spaces From A String
» Dynamically Add/Remove rows in HTML ta...
» TABLESPACE: List tablespaces, files, ...
» TABLESPACE: Dropping Tablespaces
» TABLESPACE: Transportable tablespaces
» Remove Duplicate Lines from a File
» TIMESTAMP: SYS_EXTRACT_UTC
» TIMESTAMP: EXTRACT
» Date Functions: EXTRACT
» Extract and Display all links on a web...
» DBA Tablespaces
» String to Date
» Check number of characters in a range
» Remove all non-ASCII chars
» Extract Search Query from Referer
» De-Pluralize a String
» Extract part of a string
» Truncate Links Over X Chars long
» Remove Duplicates
» Remove extra linebreaks
» Nice 'Read More...' links
» Insert Into Middle Of Text
» Add/Remove from Select list
» Set, Get, Remove Cookies

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

$string = PREG_SPLIT( '/\s/', $string, NULL, PREG_SPLIT_NO_EMPTY );
$string = IMPLODE( '+', $string ); 
 
// ...or:
 
$string = TRIM( $string );
$string = PREG_REPLACE( '/\s+/', '+', $string ); 
 
//...or:
 
PHP Code:
$string = PREG_REPLACE( '/\s+/', '+', $string );
$string = TRIM( $string, '+' )


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org