php - Replacing special characters from URL with iconv doesn't work -



php - Replacing special characters from URL with iconv doesn't work -

i have little problem of urls. let's that $result['title'] = citroën

in url, want word become "citroen". next function right, except removes "ë", url becomes "citron".

<?php echo strtolower(preg_replace('/[^a-za-z0-9\-]/', '', str_replace(' ', '-', $result['title'])));?>

i thought solve using iconv... doesn't work. "citroën" still replaced "citron".

<?php echo strtolower(preg_replace('/[^a-za-z0-9\-]/', '', str_replace(' ', '-', iconv('utf-8', 'ascii//translit', $result['title']))));?>

so, missing here?

okay, figured out. need set target locale. next code works (so "citroën" becomes "citroen"):

<?php setlocale(lc_all, 'en_gb.utf8'); echo strtolower(preg_replace('/[^a-za-z0-9\-]/', '', str_replace(' ', '-', iconv('utf-8', 'ascii//translit', $result['titel']))));?>

php string url url-rewriting iconv

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -