phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


String: Removing Whitespace from String

Tag: basic, string   Category: PHP Basic
post: 01 Feb 2008 read: 634


PHP String tips: May be your user enter data like this "my name       is   Andi". He blame his keyboard, because begin out of order. You can help this problem by remove excessive whitespace.

We use a regular expression to find multiple whitespace, then replace with a whitespace only.


$str = ereg_replace('[[:space:]]'), ' ', trim($str));



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
CAPTCHA - part 3 : "Are you human or ....?" (Build Your CAPTCHA)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting