Created
June 5, 2018 16:01
-
-
Save faridfr/22f4449b08edbc51fc3b7f0df93bb269 to your computer and use it in GitHub Desktop.
preparing string for compare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function psfc ($string){ | |
$string = | |
strtolower(str_replace(' ', '',convert_numbers_to_english(preg_replace('/\s+/', '', $string)))); | |
return $string; | |
} | |
function convert_numbers_to_english($string) { | |
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; | |
$arabic = ['٩', '٨', '٧', '٦', '٥', '٤', '٣', '٢', '١','٠']; | |
$num = range(0, 9); | |
$convertedPersianNums = str_replace($persian, $num, $string); | |
$englishNumbersOnly = str_replace($arabic, $num, $convertedPersianNums); | |
return $englishNumbersOnly; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment