Jump to content


Photo

Trim text


  • Please log in to reply
5 replies to this topic

#1 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 12 March 2006 - 12:38 PM

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
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#2 saiko

saiko
  • Members
  • PipPipPip
  • Advanced Member
  • 37 posts

Posted 12 March 2006 - 12:41 PM

$username = $_SESSION['username']; // or wateva username equals
$username = ereg_replace(" ", "", $username);


shuld work

#3 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 12 March 2006 - 12:48 PM

cheers mate, i thought there was a way like

$username=trim($username);

well i know it does somthing, but dont know what
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 12 March 2006 - 12:52 PM

trim only removes spaces from the beginning and the end on a string, but not within a string

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 12 March 2006 - 02:10 PM

Why use
<?php $username = ereg_replace(" ", "", $username); ?>
when
<?php $username = str_replace(' ','',$username); ?>
will work just as well?

Ken

#6 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 12 March 2006 - 03:52 PM

well they both do the same thing? why not use either of them?
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users