Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

 

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
New Webmasters ask "How-To" questions here. This is where other fucking Webmasters help.

 
Thread Tools
Old 09-20-2011, 07:43 PM   #1
amateurcanada
Confirmed User
 
amateurcanada's Avatar
 
Industry Role:
Join Date: Jul 2001
Posts: 3,766
PHP question, I hateeeeeeeee. Easy to do i'm sure...

Hi there! e.g.

$title="i am the best"

i want the output field to be "i-am-the-best" doing a replace of spaces with dashes.

Tell me gods how to do this :D
__________________

be our partner - join nichepartners today
will.assum.producer @ AmateurCanada.com / icq: 30146166 / facebook.com/will.assum / #amateurcanada
amateurcanada is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 09-20-2011, 08:01 PM   #2
Babaganoosh
♥♥♥ Likes Hugs ♥♥♥
 
Babaganoosh's Avatar
 
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
http://us.php.net/manual/en/function.str-replace.php
Babaganoosh is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 09-21-2011, 02:14 AM   #3
webboy21
Confirmed User
 
Industry Role:
Join Date: Nov 2004
Location: The Netherlands
Posts: 573
^what he said....easy to do
__________________
Available for: CSS | XHTML | PHP | MySQL | Webdesign

webboy21 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 09-21-2011, 05:59 AM   #4
idogfy
Registered User
 
Industry Role:
Join Date: Sep 2011
Posts: 12
Copy paste that

PHP Code:
<?php
//try it with 
$title='  I  can     replace      several   spaces   ';
//you probably don't want to add a dash at the beginning or at the end of the $title if there is some space at the beginning or at the end
$title trim($title);
// \s+ is the "pattern" you want to replace with dashes
$new_title preg_replace('/\s+/','-',$title);
echo 
$new_title;
Have fun with title and dashes

Last edited by idogfy; 09-21-2011 at 06:02 AM..
idogfy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 09-21-2011, 02:24 PM   #5
islandfreaks
Registered User
 
islandfreaks's Avatar
 
Industry Role:
Join Date: Sep 2011
Location: Caribbean
Posts: 5
^ recommended solution
islandfreaks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 09-21-2011, 02:36 PM   #6
webboy21
Confirmed User
 
Industry Role:
Join Date: Nov 2004
Location: The Netherlands
Posts: 573
yup that one is even better....but if he's putting in the string himself he won't be using double spaces etc......and then the first solution is faster I think...but if he doesn't know what the string will look like..the second solution is superior
__________________
Available for: CSS | XHTML | PHP | MySQL | Webdesign

webboy21 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
 
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.