php - Modify string to seo url but keep Scandinavian letters -


i having trouble understanding how keep norwegian letters "æ ø å" in preg_replace function got modifying forum titles seo urls. website rendered in "iso-8859-1".

how want it: someurl.com/read=kjøp_og_salg

currently looks this: someurl.com/read=kj_p_og_salg

//----- seo url function ------//     public function make_seo_name($title){     $title = preg_replace('/[\'"]/', '', $title);     $title = preg_replace('/[^a-za-z0-9]+/', '_', $title);     $title = strtolower(trim($title, '_'));     return $title; } 

i tried utf8_encode/decode $title before , after preg_replace done, didn't work.

thank time!

edit:

solved, fixed "one trick pony". ended function.

public function make_seo_name($title){   $title = utf8_encode($title);   $title = preg_replace('/[\'"]/', '', $title);   $title = preg_replace('/[^a-za-z0-9\ø\å\æ]+/', '_', $title);   $title = strtolower(trim($title, '_')); return $title; } 

note: did not need change header "iso-8859-1" "utf-8"

set document encoding utf-8 or iso-8859-1 , add characters list like:

<head><meta charset="utf-8" /></head> 

and

$title = preg_replace('/[^a-za-z0-9æøå]+/', '_', $title); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -