Jump to content

Archived

This topic is now archived and is closed to further replies.

joecooper

Trim text

Recommended Posts

i have $username which is funny enough the username.

how do i remove all spaces from that? so if they try useing "Joe Cooper", it would turn it into "JoeCooper".
Thanks
Joe Cooper

Share this post


Link to post
Share on other sites
$username = $_SESSION['username']; // or wateva username equals
$username = ereg_replace(" ", "", $username);


shuld work

Share this post


Link to post
Share on other sites
cheers mate, i thought there was a way like

$username=trim($username);

well i know it does somthing, but dont know what

Share this post


Link to post
Share on other sites
trim only removes spaces from the beginning and the end on a string, but not within a string

Share this post


Link to post
Share on other sites
Why use
[code]<?php $username = ereg_replace(" ", "", $username); ?>[/code]
when
[code]<?php $username = str_replace(' ','',$username); ?>[/code]
will work just as well?

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.