Over a million developers have joined DZone.

Titlelize

·

/**
* $title = "Hello world! This is a title";
* echo Helpers_Html::titlelizeEncode($title);
* echo "
"; * echo Helpers_Html::titlelizeDecode(Helpers_Html::titlelizeEncode($title)); */ class Titlelize{ /** * Gera titulos que podem ser recuperados * @param string $string */ //return titlelizeEncode('ola mundo'):'ola-mundo' static function titlelizeEncode($string){ $slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string); return $slug; } //para usar em SQL algo como: '... title LIKE ?', titlelizeDencode('ola-mundo') //return 'ola?mundo' static function titlelizeDecode($string){ $slug=preg_replace('/-/', '?', $string); return $slug; } }
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}