durangod
12-06-2010, 03:19 PM
hi, im curious if i have the below code why is my string length 1 after POST if i enter 5 spaces. should it not be null
//get rid of whitespace
$var['username'] = preg_replace('/\s\s+/', ' ', $var['username']);
$stlen = strlen($var['username']);
update: or am i just replacing it with itself basically..
would it be better this way
$var['username'] = str_replace(' ', '', $var['username']);
if someone enters any spaces i want them removed i can capture string length.
//get rid of whitespace
$var['username'] = preg_replace('/\s\s+/', ' ', $var['username']);
$stlen = strlen($var['username']);
update: or am i just replacing it with itself basically..
would it be better this way
$var['username'] = str_replace(' ', '', $var['username']);
if someone enters any spaces i want them removed i can capture string length.