Saturday, September 26, 2009

Strip whitespaces

I am saving a field in a form and just messing around by entering  A        B           C
After the save the data is displayed as A B C ...ok fine
 
Go back to edit what i entered and it shows up as A        B           C
 
 
in my controller:
$clean = new Sanitize();
       // Sanitize the data
       $this->data = $clean->clean($this->data);
 
How can i strip out all extra spaces only allowing 1 between words? Preferably before the save so it is cleaned up before the database.
 
Thanks,
 
Dave

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: