PHP Basics : Removing White Space / HTML Tags From A String

Hey Wuup readers. I’ve got a simple post here for those learning PHP, or even the more seasoned programmer. If you’re looking for a simple way to to remove white space from strings, and strip html tags from strings too, try this out. It can be handy if you don’t want people to abuse a form or field in an application:

<?php

$example = " test  ff       1  <br > </p> hi     ";

$result = rtrim($example);

echo trim(strip_tags($result));

?>

Tags: ,

Author:Alan Hamlyn

-- Alan Hamlyn Founder of Wuup
  • http://sovit.biz/php-basics-removing-white-space-html-tags-from-a-string-wuup/ PHP Basics : Removing White Space / HTML Tags From A String | Wuup

    [...] the rest here: PHP Basics : Removing White Space / HTML Tags From A String | Wuup SHARETHIS.addEntry({ title: "PHP Basics : Removing White Space / HTML Tags From A String | Wuup", [...]

  • http://www.critiquedirect.com/simple-php . o O ( Simple PHP Reviewed: Scam or Serious? )

    [...] may also want to check out: PHP Basics : Removing White Space / HTML Tags From A String | Wuupe-Books Baba » Smarty PHP Template Programming And ApplicationsWeb Developer Plus – [...]