how to change to english number to nepali number in php

0 votes

I want to change the English numerals to Nepali one up to 2 digits. For example: if I enter 1 it should return १ and if I enter 41 it should return ४१ and I have to store ४१ in DB and show it in the front end. 
This is what I have done till now:

function convertNos($nos){
  switch($nos){
    case"०":return 0;
    case"१":return 1;
    case"२":return 2;
    case"३":return 3;
    case"४":return 4;
    case"५":return 5;
    case"६":return 6;
    case"७":return 7;
    case"८":return 8;
    case"९":return 9;
    case"0":return"०";
    case"1":return"१";
    case"2":return"२";
    case"3":return"३";
    case"4":return"४";
    case"5":return"५";
    case"6":return"६";
    case"7":return"७";
    case"8":return"८";
    case"9":return"९";
   }
}

Can someone help me solve this?

May 28, 2022 in PHP by Kichu
• 19,050 points
438 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to change the session timeout in PHP?

Hello @kartik, Put $_SESSION['login_time'] = time(); into the previous authentication ...READ MORE

answered Sep 15, 2020 in PHP by Niroj
• 82,880 points
4,021 views
0 votes
1 answer

How to change php version in htaccess in server?

Hello, To switch to PHP 4.4: AddHandler application/x-httpd-php4 .php To ...READ MORE

answered Nov 4, 2020 in PHP by Niroj
• 82,880 points
2,722 views
0 votes
1 answer

How do I convert a string to a number in PHP?

You don't have to do this, since ...READ MORE

answered Feb 23, 2022 in PHP by Aditya
• 7,680 points
425 views
0 votes
1 answer

How to merge two arrays while keeping keys instead of reindexing in php?

Hello, Considering that you have $replaced = array('1' => ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,880 points
2,518 views
0 votes
1 answer

How to get the client IP address in PHP ?

Hello, Here is a code sample of a good ...READ MORE

answered Apr 8, 2020 in PHP by Niroj
• 82,880 points
6,541 views
0 votes
1 answer

How to implement a callback in PHP?

Hello, Implementation of a callback is done like ...READ MORE

answered Apr 15, 2020 in PHP by Niroj
• 82,880 points
677 views
0 votes
1 answer

PHP Convert String to SEO Friendly Url For Bengali Language Type

$string = preg_replace("/[^a-z0-9]/u", "$separator", $string);  change the ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 63,700 points
907 views
0 votes
0 answers

Laravel/ MSSQL (AWS RDS) General error: 20018 Unicode data

I'm using SQL Server with a Laravel ...READ MORE

Apr 25, 2022 in AWS by Aditya
• 7,680 points
693 views
0 votes
0 answers

Google Unicode Fonts not rendered properly in mpdf for PHP

I want to use Baloo2 Google Font ...READ MORE

Jun 9, 2022 in PHP by Kichu
• 19,050 points
1,352 views
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
1,213 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP