Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP slugifying HTML entity code backwards R

Tags:

php

I'm trying to create some clean URLs for artist names. I'm using the following to parse Pearl Jam to pearl-jam. All is fine until it tries to process KoЯn. Instead of returning korn, it is returning koand1071n. In my database, KoЯn is actually stored as

KoЯn

I'm using this code below. What can I do to handle the backwards R?

$delimiter = "-";
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = str_replace("\$", "s", $clean); 
$clean = preg_replace( '/&/', 'and', $clean );
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
$clean = strtolower(trim($clean, '-'));
like image 743
Mike Avatar asked May 15 '26 07:05

Mike


1 Answers

Just replace Я with a r with str_replace like you do for $

$clean = str_replace("Я", "r", $clean); 

or

$clean = str_replace("Я", "r", $clean); 
like image 89
felipep Avatar answered May 16 '26 21:05

felipep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!