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
Post a Comment