Welcome to WebmasterWorld Guest from 126.96.36.199
I would like to take some data, say a string like "This is my site" and use php to take that and turn it into "this-is-my-site" for example.
Is there a function that does this? I assume I would store the string in a variable, like $txt="this is my site" and then output the new string into another variable.
If anyone can point me towards a function that will do this, that'd be great. I'm obviously a noob at php :)
Do you mean something like this?
$text = "example.com";
echo '<a href="http://www'.$text.'">'.$text.'</a>';
Or do you mean that you want to transform specific words in a body of text into a link by searching for them? (something maybe with preg_replace)
Can you please specify if I'm thinking incorrectly?
Sorry for my misunderstanding
I'm trying to take a sentence such as "my sentence is this" and be able to use it as a url like "my-sentence-is-this.html"
I think I may have found a different way of doing this, based on some variables in the script. For example one variable returns the filename "image.jpg". I'd like to take that and strip off the .jpg.
Would I do something like:
$filename = image.jpg
$new_url = preg_replace ($filename)
I know I'm missing a step. Do I need to explode the $filename variable?