Error: Could not fetch http://thedevnet.com/wp-content/plugins/gd-star-rating/css/gdsr.css.php?t=0&s=a10i10m20k20c05r05%23121620243046%23121620243240%23s1pchristmas%23s1pcrystal%23s1pdarkness%23s1poxygen%23s1goxygen_gif%23s1pplain%23s1ppumpkin%23s1psoft%23s1pstarrating%23s1pstarscape%23t1pclassical%23t1pstarrating%23t1gstarrating_gif&ver=1.7.2 for caching. You might need to exclude this file in WP Minify options. The Developer Network – Trim Excess Whitespace

Trim Excess Whitespace

This snippet is useful when your input is full of tons of extra unwanted whitespace. Say if you are making a chat program and someone just hammers on the spacebar just a little too much.

Snippet:

  1. <?
  2.  // this function will trim out excess whitespace
  3.  // this will take something like this " h    i"
  4.  // .. and make it into this "h i"
  5.  // http://thedevnet.com/php/snippets/trim-excess-whitespace/
  1.  
  2.  function trim_excess($str)
  3.  {
  4.   $str = trim(preg_replace('/\s+/', ' ',  $str));
  5.   return $str;
  6.  }
  7. ?>

Example:

  1. <?
  2.  $str = trim_excess($str);
  3. ?>
GD Star Rating
loading...

Originally posted 2009-10-17 21:07:15.

Popularity: 10%

Posted by irbobo   @   21 August 2010

Related Posts

Like this post? Share it!

RSS Digg Twitter StumbleUpon Delicious Technorati Facebook

1 Comments

Comments
Oct 23, 2009
5:53 pm
#1 irbobo :

Found this one good for filtering input for shoutboxes or chat programs.

GD Star Rating
loading...
Leave a Comment

You must be logged in to post a comment.

Previous Post
« Image Captcha Spam Prevention
Next Post
PHP Generate RSS Feeds »
Powered by Wordpress   |   Lunated designed by ZenVerse