RE: Strip whitespaces

2009-09-26 Thread Dave Maharaj :: WidePixels.com

Thanks!

I am just getting to the point of testing saving data and trying to cleanup
junk I attempt to save.

Basically the app I went thru all the fields in forms and all of them all I
want to allow is words and numbers so paranoid clean works but the forms are
serialized so I have to use clean for that?
Occasional email or url but the validation will take care of that or do you
still need to check that data?

Little lost on the whole sanitize...make the data safe to save, but when
reading the cookbook 

'odd_spaces' => true,
'encode' => true,
'dollar' => true,
'carriage' => true,
'unicode' => true,
'escape' => true,
'backslash' => true

I have no clue what these would or would not beused for under what
condition.

Thanks again

Dave 

-Original Message-
From: brian [mailto:bally.z...@gmail.com] 
Sent: September-26-09 2:01 PM
To: cake-php@googlegroups.com
Subject: Re: Strip whitespaces


preg_replace('/\s\s+/', ' ', $str)

But, if you have a single whitespace character other than space (eg.
tab), it'll be retained.

On Sat, Sep 26, 2009 at 12:24 PM, Dave Maharaj :: WidePixels.com
 wrote:
> 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 AB   
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Strip whitespaces

2009-09-26 Thread brian

preg_replace('/\s\s+/', ' ', $str)

But, if you have a single whitespace character other than space (eg.
tab), it'll be retained.

On Sat, Sep 26, 2009 at 12:24 PM, Dave Maharaj :: WidePixels.com
 wrote:
> I am saving a field in a form and just messing around by
> entering  AB   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 AB   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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---