Get rid of blank spaces

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
Anarking
Forum Newbie
Posts: 24
Joined: Wed Feb 11, 2009 11:29 am

Get rid of blank spaces

Post by Anarking »

Hi there


Im having problem entering something into my database, I need to remove the blank spaces automatically and replace them with '_'


How do I do this?

cheers
nyoka
Forum Commoner
Posts: 45
Joined: Thu Apr 09, 2009 12:53 pm

Re: Get rid of blank spaces

Post by nyoka »

Assuming you have the data in a variable called $data the follwoing code will work.

Code: Select all

<?php
$data = str_replace(" ", "_", $data);
?>
Post Reply