Return to Snippet

Revision: 48914
at July 12, 2011 22:43 by plesh


Initial Code
/**
 * Used to give the full hyperlink for news/events items
 *
 * @param $type string - events/news
 * @param $id int - ID of item for link 
 * @param $title string - item title for link to strip bad chars
 **/
public function seo_slug ( $type, $id, $title ) 
{
	// strip bad chars
	$slug = trim(strtolower(preg_replace("/[^a-zA-Z0-9\s]/", "", $title)));
	$slug = str_replace('  ','-', $slug);
	$slug = str_replace(' ','-', $slug);
	
	$url = '/'.$type.'/d/'.$id.'/'.$slug.'/';
	
	return $url;
}

Initial URL


Initial Description
Replace non alpha-numeric characters with PHP

Initial Title
Filter alphabetic characters only - PHP

Initial Tags
php

Initial Language
PHP