[resolved] replacing a space with nothing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

[resolved] replacing a space with nothing

Post by ibanez270dx »

Hi,
I need to have a little snippit of code that takes out all of the spaces from a variable. For example, I need to replace " " with "" from $variable. If you can understand what I mean, please help!

Thanks,
- Jeff
Last edited by ibanez270dx on Mon Jul 31, 2006 1:02 pm, edited 1 time in total.
klarinetking
Forum Commoner
Posts: 59
Joined: Mon Jul 24, 2006 9:43 am

Post by klarinetking »

Hi,

str_replace

ie

Code: Select all

$variable = str_replace(' ', '', $variable)
klarinetking
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Code: Select all

str_replace(' ','',$string);
The PHP manual is your friend: str_replace()
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

Post by ibanez270dx »

awesome, thanks!
Post Reply