PHP Script to create URL from string. It retails only URL Safe characters in the strings. So, now easily create URL Slug from text string for your Search engine optimization needs.
<?php
/*
Name : PHP function to Create URL Slug from a text string
It is great tool for generating SEO URLs.
*/
function createUrlSlugFromString($string){
// Remove spaces from front and end of the string
$string = strtolower(trim($string));
// Change all non-alphanumeric character sequences to -
$string = preg_replace('/[^a-z0-9-]/', '-', $string);
// Change multiple hyphens to single hyphens
$urlSlug = preg_replace('/-+/', "-", $string);
// Remove trailing - from the slug
$urlSlug=trim($urlSlug,"-");
// We are done! Now return the sluf back.
return $urlSlug;
} // End of Create URL Slug from a text string function
// Calling the URL Slug creation function
echo createUrlSlugFromString ( " This is some text with multiple spaces and punctionations (,.?)");
?>
PHP snippet to parse a text and remove all non alphanumeric characters from it.
Price $5 Order Now
I want a function to find number of occurrences of a word in a given text and then give their positions as comma separated list.
Price $5 Order Now
I want a function to validate a given and tell if it safe URL slug i.e. it should check that it does not have any special characters, spaces or any non-alphanumeric characters except hyphens
Price $5 Order Now
A very simple php snippet to check if an email id is valid or not. If the email address is...
PHP Script to scan a text and extract all email ids contained in the text. It outputs email addresses as...
PHP Script to extract all links from a web page. This PHP Snippet reads the contents of a web page...
This is a simple PHP function to parse text provided and automatically hyperlink the links in the text.
This PHP function extracts all numbers from a String and prints them as a comma separated list of numbers. Ready...
This is a simple function written in PHP to generate keywords from any text. Just pass any free text to...
This PHP Code snippet lists all files in a folder and hyperlinks them accordingly. Very clean, easy to use function....
100% Free PHP folder to gallery script. Just give the name of folder and it will generate gallery of all...