Recent News: This is the New concept of iJerick’s Website!


You are not connected. Please login or register

Converting page titles to URL friendly titles

Go down  Message [Page 1 of 1]

___zalvaje___

___zalvaje___

Administrator

This is the conversion method used by evil walrus to convert script titles to URL titles. Removes all special characters, except hyphens, underscores, periods, commas and forward slashes, which are converted to underscores. Two or more consecutive underscores are converted to a single underscore.


<?php

// written by Aaron Hall, evilwalrus.org

// free to use, modify and redistribute without notification

$title = "This is a script -- uses PHP/MySQL! __cool!__ ";

$title = ereg_replace("[^A-Za-z0-9_\-\./, ]", "", $title); // remove special characters

$title = str_replace(array('.','-','/',','), " ", $title); // replace legal characters with spaces

$title = trim($title); // remove leading and trailing whitespace

$title = ereg_replace(" {1,}", "_", $title); // convert one or more consecutive spaces to a single underscore

$title = ereg_replace("_{2,}", "_", $title); // convert two or more consecutive underscores to a single underscore



echo $title;

// prints "This_is_a_script_uses_PHP_MySQL_cool";



?>

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

Axzido's Advertisement Space
$10 a Month

850px X 120px