Replacing numerals with foreign digits (more than just str_replace?)

In the English version of a site of mine,

$tpl->assign('TXT', array( 'search results' . ' (' . (isset($SEARCH['rows']) ? (int) $SEARCH['rows'] : '0') . ')', '', '', '', '' ));

returns the text “search results (0)” if there are no search results, “search results (1)” if there is one search result, “search results (2)” if there are two, “search results (3)” if there are three, and so on.

For the Arabic version of the same site,

$tpl->assign('TXT', array( 'نتائج البحث' . ' (' . (isset($SEARCH['rows']) ? (int) $SEARCH['rows'] : '0') . ')', '', '', '', '' ));

returns the same text, but in Arabic [“نتائج البحث”]. However, the “0”, “1”, “2”, “3”, etc., inside of the parenthesis [the result of [font=courier]’ . (isset($SEARCH[‘rows’]) ? (int) $SEARCH[‘rows’] : ‘0’) . '[/font]] will always be generated as the familiar “Arabic numerals”. I want to substitute them for “٠”, “١”, “٢”, “٣”, etc. (which will look like “٠”, “١”, “٢”, “٣”, etc.). I may be looking at this from the wrong angle, but I don’t see how I can substitute a value for a string that doesn’t exist yet. (The string doesn’t exist until it is displayed as a result of someone doing a search.) I just need to know which direction to head next; I’m not asking for someone to code a solution. [The matter of the language is irrelevant; suppose I wanted each digit to be replaced with a lowercase letter, so that “0123456789” displayed as “jabcdefghi” instead.]

I’m going to need more information.

How are you deciding what to display?

Example:
[php]<?php
session_start();
$_SESSION[‘lang’] = ‘en’;

$lang = [
‘en’ => [1,2,3,4,5],
‘ar’ => [‘ن’,‘ت’,‘ا’,‘ئ’,‘ج’],
];

foreach( $lang[$_SESSION[‘lang’]] as $num ){
echo “

{$num}

”;
}

[/php]

Change the value of $_SESSION[‘lang’] to change the results.

Sponsor our Newsletter | Privacy Policy | Terms of Service