banner I am Dev. A Freelance Web Developer from India. I have been working on for 2 years on PHP/MySQL, AJAX and related coding.

And personally I almost like everything that is OpenSource. I usally experiement with different opensource projects like RubyOnRails, OpenSocial, Facebook API and many more. More...
Sep
20th

PHP Function To make URL Friendly Strings

Author: Dev | Files under PHP

Here is another PHP function which convert strings used for SEO URL Friendly or Permalinks.

PHP:
  1. function make_friendly($string){
  2. $string = strtolower($string);
  3. $string = ereg_replace("[^a-zA-Z0-9 ]", "", $string);
  4. $string = ereg_replace(" +", " ", $string);
  5. $string = str_replace(" ", "-", $string);
  6. $string = $string;
  7. return $string;
  8. }

For example consider the following call to make_friendly:

PHP:
  1. echo make_friendly("Did n't this work?");

The output will be:

did-nt-this-work

Like this post? Want to receive more like these!

Then, enter your email address here:

Delivered by FeedBurner


Do you like this article? then

Post a Comment