joecooper Posted March 12, 2006 Share Posted March 12, 2006 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".ThanksJoe Cooper Quote Link to comment https://forums.phpfreaks.com/topic/4744-trim-text/ Share on other sites More sharing options...
saiko Posted March 12, 2006 Share Posted March 12, 2006 $username = $_SESSION['username']; // or wateva username equals$username = ereg_replace(" ", "", $username);shuld work Quote Link to comment https://forums.phpfreaks.com/topic/4744-trim-text/#findComment-16645 Share on other sites More sharing options...
joecooper Posted March 12, 2006 Author Share Posted March 12, 2006 cheers mate, i thought there was a way like$username=trim($username);well i know it does somthing, but dont know what Quote Link to comment https://forums.phpfreaks.com/topic/4744-trim-text/#findComment-16650 Share on other sites More sharing options...
wildteen88 Posted March 12, 2006 Share Posted March 12, 2006 trim only removes spaces from the beginning and the end on a string, but not within a string Quote Link to comment https://forums.phpfreaks.com/topic/4744-trim-text/#findComment-16651 Share on other sites More sharing options...
kenrbnsn Posted March 12, 2006 Share Posted March 12, 2006 Why use[code]<?php $username = ereg_replace(" ", "", $username); ?>[/code]when[code]<?php $username = str_replace(' ','',$username); ?>[/code]will work just as well?Ken Quote Link to comment https://forums.phpfreaks.com/topic/4744-trim-text/#findComment-16667 Share on other sites More sharing options...
joecooper Posted March 12, 2006 Author Share Posted March 12, 2006 well they both do the same thing? why not use either of them? Quote Link to comment https://forums.phpfreaks.com/topic/4744-trim-text/#findComment-16683 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.