// /My/View/Helper/Prepareforurl.php
<?php
class My_View_Helper_Prepareforurl extends Zend_View_Helper_Abstract
{
public function prepareforurl($item) {
// set and remove bad characters
$badChars = '#[^-a-zA-Z0-9_ ]#';
$item = preg_replace($badChars, '', $item);
$item = trim($item);
// change all dashed, underscores, spaces to dashes
$item = preg_replace('#[-_ ]+#', '-', $item);
return $item;
}
}
?>
|