https://github.com/riyadhahmed/convert-english-number-to-unicode
Simple php code to Convert English number to Unicode or Unicode to English
https://github.com/riyadhahmed/convert-english-number-to-unicode
bangla-number-convert convert-english-number-to-unicode php unicode
Last synced: 20 days ago
JSON representation
Simple php code to Convert English number to Unicode or Unicode to English
- Host: GitHub
- URL: https://github.com/riyadhahmed/convert-english-number-to-unicode
- Owner: Riyadhahmed
- Created: 2019-01-03T07:09:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-03T07:43:22.000Z (over 6 years ago)
- Last Synced: 2025-02-15T08:24:05.887Z (2 months ago)
- Topics: bangla-number-convert, convert-english-number-to-unicode, php, unicode
- Language: PHP
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Convert English number to Unicode or Unicode to English
Simple php code to Convert English number to Unicode or Unicode to EnglishYou can add this code your any php framework
For Codigniter pls follow
Create a helper php file in application/helpers folder like convert_helper.php
Then load your helper file using autoload. Go to config/autoload.php file and add you file name into $config['helpers'] = 'convert'
Now you can access this function any where in your project
## Using OOP PHP Class Functionclass NumberConverter {
public static $unicode = array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০");
public static $english = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
public static function unicode($number) {
return str_replace(self::$unicode, self::$english, $number);
}
public static function english($number) {
return str_replace(self::$english, self::$unicode, $number);
}
}echo 'This is an unicode number ১২৩৪৫৬ which convert to english number ' . NumberConverter::unicode(" ১২৩৪৫৬"). '
';
echo 'This is an english number 123456 which convert to unicode number ' . NumberConverter::english('123456'). '
';
Output :
// This is an unicode number ১২৩৪৫৬ which convert to english number 123456
// This is an english number 123456 which convert to unicode number ১২৩৪৫৬
## // Using Normal PHP Functionif (!function_exists('unicode')) {
function unicode($number)
{
$unicode = array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০");
$english = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
$value = str_replace($unicode, $english, $number);return $value;
}
}if (!function_exists('english')) {
function english($number)
{
$unicode = array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০");
$english = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
$value = str_replace($english, $unicode, $number);return $value;
}
}echo 'This is an unicode number ১২৩৪৫৬ which convert to english number ' . unicode('১২৩৪৫৬'). '
';
echo 'This is an english number 123456 which convert to unicode number ' . english('123456'). '
';
Output :
// This is an unicode number ১২৩৪৫৬ which convert to english number 123456
// This is an english number 123456 which convert to unicode number ১২৩৪৫৬Find me on Facebook : [ My Facebook profile link](https://www.facebook.com/morshed.riyad) \
Find me on Linkedin : [My Linkedin profile link](https://www.linkedin.com/in/monjur-morshed-riyadh-6aaba465/) \
Email me : [email protected]