Quick Search:
Oracle PL/SQL Code Library
Find Or Post Oracle Jobs
Oracle Discussion & Chat
 PHP Code: Remove Extra Spaces From A String Jump to:  
Category: >> PHP Code >> Remove Extra Spaces From A String Bookmark and Share

<< 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
» 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 ); 
PHP Code:
$string = PREG_REPLACE( '/\s+/', '+', $string );
$string = TRIM( $string, '+' )

Oracle Magazine
and Oracle White Papers

SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 34 users online    © 2009 psoug.org

Forgot your password?