Sharif wrote:Hello all,
I am hoping someone has already written this function and they can give it to me... I am SWAMPED WITH WORK!!!
Looking for something simple that will do this:
Turn: Hello!!! My name's Jack: You can call me whatevr;!@!$#@#
TO: hello-my-names-jack-you-can-call-me-whatever
This is for url rewriting. So I am trying to turn content pulled straight from the DB into search engine/url friendly format. Thanks for anyhelp.
You will use two functions to do this: implode and explode.
First put that text into a string, like so:
$string = "Hello!!! My name's Jack: You can call me whatever";
Then, use the explode function to put all the text into an array by taking out the spaces:
$explodestring = explode(" ", $string);
Lastly use the implode function to put a dash between each array object:
$implodestring = implode("-", $explodestring);
The entire script will look like so:
<?php
$string = "Hello!!! My name's Jack: You can call me whatever";
$explodestring = explode(" ", $string);
$implodestring = implode("-", $explodestring);
?>
hope this helps.
-tucker-