Jump to content
php.lv forumi

php funkcija


rebuilder

Recommended Posts

$s=preg_replace("/[^a-zA-Z0-9 ]/", "", $s); //aizvāc visu, kas nav A-Z,a-z,0-9 un atstarpe.

 

šis aizvāks garos un mīkstos patskaņus, bet man liekas viņš domāja to aizvietots ar parastiem.. nāksies vien ar roku sarakstiik kurus simbolus aizvietot.. ā ar a.. bet funkcija jau der :D

Edited by sheps
Link to comment
Share on other sites

ok, iebarosim ar karotīti:

/**
* Funkcija pārkonverte virkni uz SEO virkni (slug)
* @param string $str Konvertējamā virkne
* @param string $separator Tukšumusimbolu aizstājējs
* @return string Konvertētā virkne
*/
function getSeo($str, $separator = '-'){
$str = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str);
$str = trim(preg_replace('/[^ A-Za-z0-9_-]/', ' ', $str));
return preg_replace('/[ -]+/', $separator, $str);
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...