hello all, I managed to make a function but i do not know how to use it if i get the inf. from database. here is my function function safename($title) PHP: I want to use it in here <?=$item[title]?>. PHP: <?php while($item = mysql_fetch_array($portfolio)) { ?> <a href="/links/<?=$item[id]?>/<?=$item[title]?>.html" class="link2"><?=$item[title]?></a> <?php } ?> PHP: any idea? thanks
this is the function function safename($title){ // replaces every unwanted character form a string with - ; $title = str_replace("&", "and", $title); $arrStupid = array('feat.', 'feat', '.com', '(tm)', ' ', '*', "'s", '"', ",", ":", ";", "@", "#", "(", ")", "?", "!", "_", "$","+", "=", "|", "'", '/', "~", "`s", "`", "\\", "^", "[","]","{", "}", "<", ">", "%", "â„¢"); $title = htmlentities($title); $title = preg_replace('/&([a-zA-Z])(.*?);/','$1',$title); // get rid of bogus characters $title = strtolower("$title"); $title = str_replace(".", "", $title); $title = str_replace($arrStupid, "-", $title); $flag = 1; while($flag){ $newtitle = str_replace("--","-",$title); if($title != $newtitle) { $flag = 1; } else $flag = 0; $title = $newtitle; } $len = strlen($title); if($title[$len-1] == "-") { $title = substr($title, 0, $len-1); } return $title; } PHP: My table is: files my field is: title my sql while($item = mysql_fetch_array($portfolio)){ PHP: I use: <?=$item[title]?> PHP: to get the title row at the moment Thanks