在PHP echo或print中更改语言

Please help me to solve this issue. I'm not sure is it possible or not! I need a small tricky solution.

<?php include_once"system/hijri_calendar.php";               
echo (new hijri\datetime()) -> format ('_j');
?>

Above code gives me an output of integer (1...30) in English.

Now, After echo, I want to change this English language to other languages. Example:

Say Above code gives me an output 1 I want to change this output (1) to other languages (১)

If I get you right you are trying to get the value from one array based on the value and key from another array. You can use array_search() to find the key from array based on value

<?php

$en = array(1,2,3,4,5,6,7,8,9,0);
$bn = array('১','২','৩','৪','৫','৬','৭','৮','৯','০');

var_dump(array_search(5, $en)); // gives the key 4 from $en where value is 5 
                                 // array keys strart with 0

// so you can do
var_dump($bn[array_search(5, $en)]);  // gives ৬

PHPFiddle to play with

Quick and dirty:

function __($number, $lang)
{

    if ($lang == 'en') {
        return $number;
    }

    $translate = array();
    $translate['bn'] = array(
        '1' => '১',
        '2' => '২',
        '3' => '৩',
        '4' => '৪',
        '5' => '৫',
        '6' => '৬',
        '7' => '৭',
        '8' => '৮',
        '9' => '৯',
        '0' => '০'
    );

    $translate['th'] = array(
        '1' => '๑',
        '2' => '๒',
        '3' => '๓',
        '4' => '๔',
        '5' => '๕',
        '6' => '๖',
        '7' => '๗',
        '8' => '๘',
        '9' => '๙',
        '0' => '๐'
    );

    $digits = str_split($number,1);
    $return_this = '';
    foreach($digits as $digit){
        $return_this .= $translate[$lang][$digit];
    }
    return $return_this;
}

echo __('905','bn');

Break down, if the lang is en you get what you give, if bn or th, it'll break the number apart and rebuild it using the requested array.

This is basically how I do I18n except the arrays for each language are in their own files.

I've changed the arrays slightly to simplify things. If the array is in the order of the digits (so I've moved the 0 element to position 0 in the array) you can use...

$bn = array('০','১','২','৩','৪','৫','৬','৭','৮','৯');
$in = "18";
$out = "";
foreach ( str_split($in) as $ch ) {
    $out .= $bn[$ch];
}
echo $out;