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