আমি চাচ্ছি যে কেউ যদি ইউনিকোডে ০,১,২....৮,৯ ইনপুট দেয় আমি সেগুলোকে যথাক্রমে 0,1,2....8,9 এ কনভার্ট করব। কিন্তু এটা করার মত কোন রিসোর্স পাচ্ছিনা। str_ireplace() দিয়ে ট্রাই করেছি। এটার ডকুমেন্টে বলা আছে সে এটা UTF-8 সাপোর্ট করে কিন্তু আমার এখানে তো আমি পাচ্ছিনা। এ ক্ষেত্রে কি করা যায়?

asked 23 Nov '16, 16:06

mabdsalam12's gravatar image

mabdsalam12
475120



// convert bangeli numeric value to english numeric value
function Bn2En($input)
{
    $bn_digits=array('০','১','২','৩','৪','৫','৬','৭','৮','৯');
    $en_digits=array('0','1','2','3','4','5','6','7','8','9');
    return $output = str_replace($bn_digits,$en_digits, $input); 
}
echo Bn2En('১২৩৪৫৬৭৮৯০');
permanent link

answered 24 Nov '16, 05:46

Bashar's gravatar image

Bashar
363

edited 24 Nov '16, 05:47

I hope, This will help to you.

$array = [
    '<img src="emoticons/{{value}}" height="18" width="18">' => [
        ':)' => 'smile.png', 
        ';)' => 'wink.png' 
    ],
    '<br>' => ['\n', '\r'],
    '1' => '১',
    '2' => '২'
];

function filterText($array, &$msg) {
    foreach($array as $key => $value) {
        if(is_array($value)) {
           if(array_keys($value) !== range(0, count($value) - 1)) {
              foreach($value as $k => $v) {
                  $msg = str_replace($k, str_replace('{{value}}', $v, $key), $msg);
              }
           } else {
               for($i = 0;$i < count($value);$i++) {
                   $msg = str_replace($value[$i], $key, $msg);
               }
           }
        } else {
            $msg = str_replace($value, $key, $msg);
        }
    }
}

$msg = '১২lettercussword :) \n';
filterText($array, $msg);
echo $msg;
permanent link

answered 23 Nov '16, 16:34

Minhaj%20Hasan's gravatar image

Minhaj Hasan
5942936

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×56
×31
×17
×1

question asked: 23 Nov '16, 16:06

question was seen: 837 times

last updated: 24 Nov '16, 05:47