How to replace entire numbers in a website to persian numbers via PHP?












6














How to replace entire numbers in body or website html to persian numbers via PHP?

I want to replace all numbers in my website for all pages .



Code:



function ta_persian_num($string) {
//arrays of persian and latin numbers
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$latin_num = range(0, 9);

$string = str_replace($latin_num, $persian_num, $string);

return $string;
}


My Code work for Client Side:



<script>
$(document).ready(function(){
persian={0:'۰',1:'۱',2:'۲',3:'۳',4:'۴',5:'۵',6:'۶',7:'۷',8:'۸',9:'۹'};
function traverse(el){
if(el.nodeType==3){
var list=el.data.match(/[0-9]/g);
if(list!=null && list.length!=0){
for(var i=0;i<list.length;i++)
el.data=el.data.replace(list[i],persian[list[i]]);
}
}
for(var i=0;i<el.childNodes.length;i++){
traverse(el.childNodes[i]);
}
}
traverse(document.body);
});
</script>









share|improve this question




















  • 3




    So, what's the problem with provided code?
    – u_mulder
    Nov 12 at 14:23












  • I'm new with PHP how should I use this function for all body numbers,I mean how to replace entire numbers in body automaticaly
    – Sedric Heidarizarei
    Nov 12 at 14:24








  • 3




    Use javascript instead
    – Mohammad
    Nov 12 at 14:29






  • 1




    Maybe output buffering help you. Using it, you can get all printed content in variable and run your function on it.
    – Mohammad
    Nov 12 at 14:42








  • 1




    I think everybody told you already. Use JS. (Don't know what you wanna do with CSS though)
    – Lithilion
    Nov 15 at 12:17
















6














How to replace entire numbers in body or website html to persian numbers via PHP?

I want to replace all numbers in my website for all pages .



Code:



function ta_persian_num($string) {
//arrays of persian and latin numbers
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$latin_num = range(0, 9);

$string = str_replace($latin_num, $persian_num, $string);

return $string;
}


My Code work for Client Side:



<script>
$(document).ready(function(){
persian={0:'۰',1:'۱',2:'۲',3:'۳',4:'۴',5:'۵',6:'۶',7:'۷',8:'۸',9:'۹'};
function traverse(el){
if(el.nodeType==3){
var list=el.data.match(/[0-9]/g);
if(list!=null && list.length!=0){
for(var i=0;i<list.length;i++)
el.data=el.data.replace(list[i],persian[list[i]]);
}
}
for(var i=0;i<el.childNodes.length;i++){
traverse(el.childNodes[i]);
}
}
traverse(document.body);
});
</script>









share|improve this question




















  • 3




    So, what's the problem with provided code?
    – u_mulder
    Nov 12 at 14:23












  • I'm new with PHP how should I use this function for all body numbers,I mean how to replace entire numbers in body automaticaly
    – Sedric Heidarizarei
    Nov 12 at 14:24








  • 3




    Use javascript instead
    – Mohammad
    Nov 12 at 14:29






  • 1




    Maybe output buffering help you. Using it, you can get all printed content in variable and run your function on it.
    – Mohammad
    Nov 12 at 14:42








  • 1




    I think everybody told you already. Use JS. (Don't know what you wanna do with CSS though)
    – Lithilion
    Nov 15 at 12:17














6












6








6


2





How to replace entire numbers in body or website html to persian numbers via PHP?

I want to replace all numbers in my website for all pages .



Code:



function ta_persian_num($string) {
//arrays of persian and latin numbers
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$latin_num = range(0, 9);

$string = str_replace($latin_num, $persian_num, $string);

return $string;
}


My Code work for Client Side:



<script>
$(document).ready(function(){
persian={0:'۰',1:'۱',2:'۲',3:'۳',4:'۴',5:'۵',6:'۶',7:'۷',8:'۸',9:'۹'};
function traverse(el){
if(el.nodeType==3){
var list=el.data.match(/[0-9]/g);
if(list!=null && list.length!=0){
for(var i=0;i<list.length;i++)
el.data=el.data.replace(list[i],persian[list[i]]);
}
}
for(var i=0;i<el.childNodes.length;i++){
traverse(el.childNodes[i]);
}
}
traverse(document.body);
});
</script>









share|improve this question















How to replace entire numbers in body or website html to persian numbers via PHP?

I want to replace all numbers in my website for all pages .



Code:



function ta_persian_num($string) {
//arrays of persian and latin numbers
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$latin_num = range(0, 9);

$string = str_replace($latin_num, $persian_num, $string);

return $string;
}


My Code work for Client Side:



<script>
$(document).ready(function(){
persian={0:'۰',1:'۱',2:'۲',3:'۳',4:'۴',5:'۵',6:'۶',7:'۷',8:'۸',9:'۹'};
function traverse(el){
if(el.nodeType==3){
var list=el.data.match(/[0-9]/g);
if(list!=null && list.length!=0){
for(var i=0;i<list.length;i++)
el.data=el.data.replace(list[i],persian[list[i]]);
}
}
for(var i=0;i<el.childNodes.length;i++){
traverse(el.childNodes[i]);
}
}
traverse(document.body);
});
</script>






php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 at 15:39









Script47

8,96342143




8,96342143










asked Nov 12 at 14:22









Sedric Heidarizarei

1,44652352




1,44652352








  • 3




    So, what's the problem with provided code?
    – u_mulder
    Nov 12 at 14:23












  • I'm new with PHP how should I use this function for all body numbers,I mean how to replace entire numbers in body automaticaly
    – Sedric Heidarizarei
    Nov 12 at 14:24








  • 3




    Use javascript instead
    – Mohammad
    Nov 12 at 14:29






  • 1




    Maybe output buffering help you. Using it, you can get all printed content in variable and run your function on it.
    – Mohammad
    Nov 12 at 14:42








  • 1




    I think everybody told you already. Use JS. (Don't know what you wanna do with CSS though)
    – Lithilion
    Nov 15 at 12:17














  • 3




    So, what's the problem with provided code?
    – u_mulder
    Nov 12 at 14:23












  • I'm new with PHP how should I use this function for all body numbers,I mean how to replace entire numbers in body automaticaly
    – Sedric Heidarizarei
    Nov 12 at 14:24








  • 3




    Use javascript instead
    – Mohammad
    Nov 12 at 14:29






  • 1




    Maybe output buffering help you. Using it, you can get all printed content in variable and run your function on it.
    – Mohammad
    Nov 12 at 14:42








  • 1




    I think everybody told you already. Use JS. (Don't know what you wanna do with CSS though)
    – Lithilion
    Nov 15 at 12:17








3




3




So, what's the problem with provided code?
– u_mulder
Nov 12 at 14:23






So, what's the problem with provided code?
– u_mulder
Nov 12 at 14:23














I'm new with PHP how should I use this function for all body numbers,I mean how to replace entire numbers in body automaticaly
– Sedric Heidarizarei
Nov 12 at 14:24






I'm new with PHP how should I use this function for all body numbers,I mean how to replace entire numbers in body automaticaly
– Sedric Heidarizarei
Nov 12 at 14:24






3




3




Use javascript instead
– Mohammad
Nov 12 at 14:29




Use javascript instead
– Mohammad
Nov 12 at 14:29




1




1




Maybe output buffering help you. Using it, you can get all printed content in variable and run your function on it.
– Mohammad
Nov 12 at 14:42






Maybe output buffering help you. Using it, you can get all printed content in variable and run your function on it.
– Mohammad
Nov 12 at 14:42






1




1




I think everybody told you already. Use JS. (Don't know what you wanna do with CSS though)
– Lithilion
Nov 15 at 12:17




I think everybody told you already. Use JS. (Don't know what you wanna do with CSS though)
– Lithilion
Nov 15 at 12:17












4 Answers
4






active

oldest

votes


















4














You should better move this functionality to frontend end use javascript:



<script type="text/javascript">
var replaceDigits = function() {
var map = ["۰","۱","۲","۳","۴", "۵","۶","۷","۸","۹"]
document.body.innerHTML = document.body.innerHTML.replace(/d(?=[^<>]*(<|$))/g, function($0) { return map[$0]});
}
window.onload = replaceDigits;
</script>


Ex: https://codepen.io/anon/pen/rQWGRd



or you can include this function in any your js file which is loaded on all pages.



And also your body tag should have a onload attribute like the following:



<body onload="replaceDigits()">





share|improve this answer























  • yes, I think this way is better
    – Sedric Heidarizarei
    Nov 12 at 14:54






  • 2




    @SedricHeidarizarei So what happened to "Thanks But I have Client side Solution, I need an example for server side"? You were advised to use Javascript almost 30 minutes ago and you refused. What changed?
    – Patrick Q
    Nov 12 at 14:58










  • @patrick-q do you have any good awnser for server side?
    – Sedric Heidarizarei
    Nov 12 at 15:14



















4





+25









The nicest way to do in PHP, is using regular expressions:



$string='salam 1 23 12';
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
for($i=0;$i<10;$i++){
$string = preg_replace("/$i/", $persian_num[$i], $string);
}
print($string);


Code above, replaces all English numbers with your specified characters in Persian.






share|improve this answer























  • isnt safer use mb_ereg_replace instead preg_replace?
    – Mohsen
    Nov 21 at 11:05



















3














✅ Solved My Problem with This way:



1: Use FontCreator 9 or 10 Program.

2: Open your font in FontCreator.

3: Goto Numbers tab.

4: Paste your RTL language numbers (Persian/Hebrew/Arabic) On english numbers.



Enjoy Without any F... Functions / Extra Processing.



Photo:
Photo



Update:

It should also be replaced on Arabic too



Final View Photo
Photo2






share|improve this answer



















  • 1




    Odd, but interesting solution. Please note that users who cannot download this font will get arabic numbers displayed.
    – Lithilion
    Nov 16 at 8:05












  • @Lithilion Yes that's right, It should also be replaced on Arabic too, I updated the answer with a new Photo.
    – Sedric Heidarizarei
    Nov 16 at 11:52






  • 3




    No, thats not the point. If someone cannot load your custom font, there is a fallback to a system font (i.e. Arial, Times New Roman,...) and these will have the "standart" numbers on these places
    – Lithilion
    Nov 16 at 11:54










  • Yes True But This Solution works 99% for all users if you use all font formats(eot.woff.woff2 and ...),
    – Sedric Heidarizarei
    Nov 16 at 12:01



















2














If you really want to do this in PHP, you can concat all text/html output into the same variable and then echo it in the end. Between the the last concat and the echo you can call this function, in every .php page you echo output.



<?php
//Code...
$string = ta_persian_num($string);
echo $string;


Personally I would prefer JS for this question.






share|improve this answer























  • How to pass my page numbers from $string ? Can you write an example for index.php ? I mean something like this : ta_persian_num(document.body)
    – Sedric Heidarizarei
    Nov 12 at 14:47












  • That's the thing. There is no document.body in PHP. You have to write all the output into $stringor whatever you call it and then call this funtion.
    – Lithilion
    Nov 12 at 14:51










  • This is not a good solution because I can't write all of my output into $string
    – Sedric Heidarizarei
    Nov 12 at 15:01













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264154%2fhow-to-replace-entire-numbers-in-a-website-to-persian-numbers-via-php%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























4 Answers
4






active

oldest

votes








4 Answers
4






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














You should better move this functionality to frontend end use javascript:



<script type="text/javascript">
var replaceDigits = function() {
var map = ["۰","۱","۲","۳","۴", "۵","۶","۷","۸","۹"]
document.body.innerHTML = document.body.innerHTML.replace(/d(?=[^<>]*(<|$))/g, function($0) { return map[$0]});
}
window.onload = replaceDigits;
</script>


Ex: https://codepen.io/anon/pen/rQWGRd



or you can include this function in any your js file which is loaded on all pages.



And also your body tag should have a onload attribute like the following:



<body onload="replaceDigits()">





share|improve this answer























  • yes, I think this way is better
    – Sedric Heidarizarei
    Nov 12 at 14:54






  • 2




    @SedricHeidarizarei So what happened to "Thanks But I have Client side Solution, I need an example for server side"? You were advised to use Javascript almost 30 minutes ago and you refused. What changed?
    – Patrick Q
    Nov 12 at 14:58










  • @patrick-q do you have any good awnser for server side?
    – Sedric Heidarizarei
    Nov 12 at 15:14
















4














You should better move this functionality to frontend end use javascript:



<script type="text/javascript">
var replaceDigits = function() {
var map = ["۰","۱","۲","۳","۴", "۵","۶","۷","۸","۹"]
document.body.innerHTML = document.body.innerHTML.replace(/d(?=[^<>]*(<|$))/g, function($0) { return map[$0]});
}
window.onload = replaceDigits;
</script>


Ex: https://codepen.io/anon/pen/rQWGRd



or you can include this function in any your js file which is loaded on all pages.



And also your body tag should have a onload attribute like the following:



<body onload="replaceDigits()">





share|improve this answer























  • yes, I think this way is better
    – Sedric Heidarizarei
    Nov 12 at 14:54






  • 2




    @SedricHeidarizarei So what happened to "Thanks But I have Client side Solution, I need an example for server side"? You were advised to use Javascript almost 30 minutes ago and you refused. What changed?
    – Patrick Q
    Nov 12 at 14:58










  • @patrick-q do you have any good awnser for server side?
    – Sedric Heidarizarei
    Nov 12 at 15:14














4












4








4






You should better move this functionality to frontend end use javascript:



<script type="text/javascript">
var replaceDigits = function() {
var map = ["۰","۱","۲","۳","۴", "۵","۶","۷","۸","۹"]
document.body.innerHTML = document.body.innerHTML.replace(/d(?=[^<>]*(<|$))/g, function($0) { return map[$0]});
}
window.onload = replaceDigits;
</script>


Ex: https://codepen.io/anon/pen/rQWGRd



or you can include this function in any your js file which is loaded on all pages.



And also your body tag should have a onload attribute like the following:



<body onload="replaceDigits()">





share|improve this answer














You should better move this functionality to frontend end use javascript:



<script type="text/javascript">
var replaceDigits = function() {
var map = ["۰","۱","۲","۳","۴", "۵","۶","۷","۸","۹"]
document.body.innerHTML = document.body.innerHTML.replace(/d(?=[^<>]*(<|$))/g, function($0) { return map[$0]});
}
window.onload = replaceDigits;
</script>


Ex: https://codepen.io/anon/pen/rQWGRd



or you can include this function in any your js file which is loaded on all pages.



And also your body tag should have a onload attribute like the following:



<body onload="replaceDigits()">






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 at 16:07

























answered Nov 12 at 14:51









Alex

14.3k11736




14.3k11736












  • yes, I think this way is better
    – Sedric Heidarizarei
    Nov 12 at 14:54






  • 2




    @SedricHeidarizarei So what happened to "Thanks But I have Client side Solution, I need an example for server side"? You were advised to use Javascript almost 30 minutes ago and you refused. What changed?
    – Patrick Q
    Nov 12 at 14:58










  • @patrick-q do you have any good awnser for server side?
    – Sedric Heidarizarei
    Nov 12 at 15:14


















  • yes, I think this way is better
    – Sedric Heidarizarei
    Nov 12 at 14:54






  • 2




    @SedricHeidarizarei So what happened to "Thanks But I have Client side Solution, I need an example for server side"? You were advised to use Javascript almost 30 minutes ago and you refused. What changed?
    – Patrick Q
    Nov 12 at 14:58










  • @patrick-q do you have any good awnser for server side?
    – Sedric Heidarizarei
    Nov 12 at 15:14
















yes, I think this way is better
– Sedric Heidarizarei
Nov 12 at 14:54




yes, I think this way is better
– Sedric Heidarizarei
Nov 12 at 14:54




2




2




@SedricHeidarizarei So what happened to "Thanks But I have Client side Solution, I need an example for server side"? You were advised to use Javascript almost 30 minutes ago and you refused. What changed?
– Patrick Q
Nov 12 at 14:58




@SedricHeidarizarei So what happened to "Thanks But I have Client side Solution, I need an example for server side"? You were advised to use Javascript almost 30 minutes ago and you refused. What changed?
– Patrick Q
Nov 12 at 14:58












@patrick-q do you have any good awnser for server side?
– Sedric Heidarizarei
Nov 12 at 15:14




@patrick-q do you have any good awnser for server side?
– Sedric Heidarizarei
Nov 12 at 15:14













4





+25









The nicest way to do in PHP, is using regular expressions:



$string='salam 1 23 12';
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
for($i=0;$i<10;$i++){
$string = preg_replace("/$i/", $persian_num[$i], $string);
}
print($string);


Code above, replaces all English numbers with your specified characters in Persian.






share|improve this answer























  • isnt safer use mb_ereg_replace instead preg_replace?
    – Mohsen
    Nov 21 at 11:05
















4





+25









The nicest way to do in PHP, is using regular expressions:



$string='salam 1 23 12';
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
for($i=0;$i<10;$i++){
$string = preg_replace("/$i/", $persian_num[$i], $string);
}
print($string);


Code above, replaces all English numbers with your specified characters in Persian.






share|improve this answer























  • isnt safer use mb_ereg_replace instead preg_replace?
    – Mohsen
    Nov 21 at 11:05














4





+25







4





+25



4




+25




The nicest way to do in PHP, is using regular expressions:



$string='salam 1 23 12';
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
for($i=0;$i<10;$i++){
$string = preg_replace("/$i/", $persian_num[$i], $string);
}
print($string);


Code above, replaces all English numbers with your specified characters in Persian.






share|improve this answer














The nicest way to do in PHP, is using regular expressions:



$string='salam 1 23 12';
$persian_num = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
for($i=0;$i<10;$i++){
$string = preg_replace("/$i/", $persian_num[$i], $string);
}
print($string);


Code above, replaces all English numbers with your specified characters in Persian.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 18 at 9:09

























answered Nov 18 at 6:45









Mᴏʀᴀᴅɴᴇᴊᴀᴅ

62211029




62211029












  • isnt safer use mb_ereg_replace instead preg_replace?
    – Mohsen
    Nov 21 at 11:05


















  • isnt safer use mb_ereg_replace instead preg_replace?
    – Mohsen
    Nov 21 at 11:05
















isnt safer use mb_ereg_replace instead preg_replace?
– Mohsen
Nov 21 at 11:05




isnt safer use mb_ereg_replace instead preg_replace?
– Mohsen
Nov 21 at 11:05











3














✅ Solved My Problem with This way:



1: Use FontCreator 9 or 10 Program.

2: Open your font in FontCreator.

3: Goto Numbers tab.

4: Paste your RTL language numbers (Persian/Hebrew/Arabic) On english numbers.



Enjoy Without any F... Functions / Extra Processing.



Photo:
Photo



Update:

It should also be replaced on Arabic too



Final View Photo
Photo2






share|improve this answer



















  • 1




    Odd, but interesting solution. Please note that users who cannot download this font will get arabic numbers displayed.
    – Lithilion
    Nov 16 at 8:05












  • @Lithilion Yes that's right, It should also be replaced on Arabic too, I updated the answer with a new Photo.
    – Sedric Heidarizarei
    Nov 16 at 11:52






  • 3




    No, thats not the point. If someone cannot load your custom font, there is a fallback to a system font (i.e. Arial, Times New Roman,...) and these will have the "standart" numbers on these places
    – Lithilion
    Nov 16 at 11:54










  • Yes True But This Solution works 99% for all users if you use all font formats(eot.woff.woff2 and ...),
    – Sedric Heidarizarei
    Nov 16 at 12:01
















3














✅ Solved My Problem with This way:



1: Use FontCreator 9 or 10 Program.

2: Open your font in FontCreator.

3: Goto Numbers tab.

4: Paste your RTL language numbers (Persian/Hebrew/Arabic) On english numbers.



Enjoy Without any F... Functions / Extra Processing.



Photo:
Photo



Update:

It should also be replaced on Arabic too



Final View Photo
Photo2






share|improve this answer



















  • 1




    Odd, but interesting solution. Please note that users who cannot download this font will get arabic numbers displayed.
    – Lithilion
    Nov 16 at 8:05












  • @Lithilion Yes that's right, It should also be replaced on Arabic too, I updated the answer with a new Photo.
    – Sedric Heidarizarei
    Nov 16 at 11:52






  • 3




    No, thats not the point. If someone cannot load your custom font, there is a fallback to a system font (i.e. Arial, Times New Roman,...) and these will have the "standart" numbers on these places
    – Lithilion
    Nov 16 at 11:54










  • Yes True But This Solution works 99% for all users if you use all font formats(eot.woff.woff2 and ...),
    – Sedric Heidarizarei
    Nov 16 at 12:01














3












3








3






✅ Solved My Problem with This way:



1: Use FontCreator 9 or 10 Program.

2: Open your font in FontCreator.

3: Goto Numbers tab.

4: Paste your RTL language numbers (Persian/Hebrew/Arabic) On english numbers.



Enjoy Without any F... Functions / Extra Processing.



Photo:
Photo



Update:

It should also be replaced on Arabic too



Final View Photo
Photo2






share|improve this answer














✅ Solved My Problem with This way:



1: Use FontCreator 9 or 10 Program.

2: Open your font in FontCreator.

3: Goto Numbers tab.

4: Paste your RTL language numbers (Persian/Hebrew/Arabic) On english numbers.



Enjoy Without any F... Functions / Extra Processing.



Photo:
Photo



Update:

It should also be replaced on Arabic too



Final View Photo
Photo2







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 16 at 11:49

























answered Nov 15 at 15:05









Sedric Heidarizarei

1,44652352




1,44652352








  • 1




    Odd, but interesting solution. Please note that users who cannot download this font will get arabic numbers displayed.
    – Lithilion
    Nov 16 at 8:05












  • @Lithilion Yes that's right, It should also be replaced on Arabic too, I updated the answer with a new Photo.
    – Sedric Heidarizarei
    Nov 16 at 11:52






  • 3




    No, thats not the point. If someone cannot load your custom font, there is a fallback to a system font (i.e. Arial, Times New Roman,...) and these will have the "standart" numbers on these places
    – Lithilion
    Nov 16 at 11:54










  • Yes True But This Solution works 99% for all users if you use all font formats(eot.woff.woff2 and ...),
    – Sedric Heidarizarei
    Nov 16 at 12:01














  • 1




    Odd, but interesting solution. Please note that users who cannot download this font will get arabic numbers displayed.
    – Lithilion
    Nov 16 at 8:05












  • @Lithilion Yes that's right, It should also be replaced on Arabic too, I updated the answer with a new Photo.
    – Sedric Heidarizarei
    Nov 16 at 11:52






  • 3




    No, thats not the point. If someone cannot load your custom font, there is a fallback to a system font (i.e. Arial, Times New Roman,...) and these will have the "standart" numbers on these places
    – Lithilion
    Nov 16 at 11:54










  • Yes True But This Solution works 99% for all users if you use all font formats(eot.woff.woff2 and ...),
    – Sedric Heidarizarei
    Nov 16 at 12:01








1




1




Odd, but interesting solution. Please note that users who cannot download this font will get arabic numbers displayed.
– Lithilion
Nov 16 at 8:05






Odd, but interesting solution. Please note that users who cannot download this font will get arabic numbers displayed.
– Lithilion
Nov 16 at 8:05














@Lithilion Yes that's right, It should also be replaced on Arabic too, I updated the answer with a new Photo.
– Sedric Heidarizarei
Nov 16 at 11:52




@Lithilion Yes that's right, It should also be replaced on Arabic too, I updated the answer with a new Photo.
– Sedric Heidarizarei
Nov 16 at 11:52




3




3




No, thats not the point. If someone cannot load your custom font, there is a fallback to a system font (i.e. Arial, Times New Roman,...) and these will have the "standart" numbers on these places
– Lithilion
Nov 16 at 11:54




No, thats not the point. If someone cannot load your custom font, there is a fallback to a system font (i.e. Arial, Times New Roman,...) and these will have the "standart" numbers on these places
– Lithilion
Nov 16 at 11:54












Yes True But This Solution works 99% for all users if you use all font formats(eot.woff.woff2 and ...),
– Sedric Heidarizarei
Nov 16 at 12:01




Yes True But This Solution works 99% for all users if you use all font formats(eot.woff.woff2 and ...),
– Sedric Heidarizarei
Nov 16 at 12:01











2














If you really want to do this in PHP, you can concat all text/html output into the same variable and then echo it in the end. Between the the last concat and the echo you can call this function, in every .php page you echo output.



<?php
//Code...
$string = ta_persian_num($string);
echo $string;


Personally I would prefer JS for this question.






share|improve this answer























  • How to pass my page numbers from $string ? Can you write an example for index.php ? I mean something like this : ta_persian_num(document.body)
    – Sedric Heidarizarei
    Nov 12 at 14:47












  • That's the thing. There is no document.body in PHP. You have to write all the output into $stringor whatever you call it and then call this funtion.
    – Lithilion
    Nov 12 at 14:51










  • This is not a good solution because I can't write all of my output into $string
    – Sedric Heidarizarei
    Nov 12 at 15:01


















2














If you really want to do this in PHP, you can concat all text/html output into the same variable and then echo it in the end. Between the the last concat and the echo you can call this function, in every .php page you echo output.



<?php
//Code...
$string = ta_persian_num($string);
echo $string;


Personally I would prefer JS for this question.






share|improve this answer























  • How to pass my page numbers from $string ? Can you write an example for index.php ? I mean something like this : ta_persian_num(document.body)
    – Sedric Heidarizarei
    Nov 12 at 14:47












  • That's the thing. There is no document.body in PHP. You have to write all the output into $stringor whatever you call it and then call this funtion.
    – Lithilion
    Nov 12 at 14:51










  • This is not a good solution because I can't write all of my output into $string
    – Sedric Heidarizarei
    Nov 12 at 15:01
















2












2








2






If you really want to do this in PHP, you can concat all text/html output into the same variable and then echo it in the end. Between the the last concat and the echo you can call this function, in every .php page you echo output.



<?php
//Code...
$string = ta_persian_num($string);
echo $string;


Personally I would prefer JS for this question.






share|improve this answer














If you really want to do this in PHP, you can concat all text/html output into the same variable and then echo it in the end. Between the the last concat and the echo you can call this function, in every .php page you echo output.



<?php
//Code...
$string = ta_persian_num($string);
echo $string;


Personally I would prefer JS for this question.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 at 14:52

























answered Nov 12 at 14:40









Lithilion

7131919




7131919












  • How to pass my page numbers from $string ? Can you write an example for index.php ? I mean something like this : ta_persian_num(document.body)
    – Sedric Heidarizarei
    Nov 12 at 14:47












  • That's the thing. There is no document.body in PHP. You have to write all the output into $stringor whatever you call it and then call this funtion.
    – Lithilion
    Nov 12 at 14:51










  • This is not a good solution because I can't write all of my output into $string
    – Sedric Heidarizarei
    Nov 12 at 15:01




















  • How to pass my page numbers from $string ? Can you write an example for index.php ? I mean something like this : ta_persian_num(document.body)
    – Sedric Heidarizarei
    Nov 12 at 14:47












  • That's the thing. There is no document.body in PHP. You have to write all the output into $stringor whatever you call it and then call this funtion.
    – Lithilion
    Nov 12 at 14:51










  • This is not a good solution because I can't write all of my output into $string
    – Sedric Heidarizarei
    Nov 12 at 15:01


















How to pass my page numbers from $string ? Can you write an example for index.php ? I mean something like this : ta_persian_num(document.body)
– Sedric Heidarizarei
Nov 12 at 14:47






How to pass my page numbers from $string ? Can you write an example for index.php ? I mean something like this : ta_persian_num(document.body)
– Sedric Heidarizarei
Nov 12 at 14:47














That's the thing. There is no document.body in PHP. You have to write all the output into $stringor whatever you call it and then call this funtion.
– Lithilion
Nov 12 at 14:51




That's the thing. There is no document.body in PHP. You have to write all the output into $stringor whatever you call it and then call this funtion.
– Lithilion
Nov 12 at 14:51












This is not a good solution because I can't write all of my output into $string
– Sedric Heidarizarei
Nov 12 at 15:01






This is not a good solution because I can't write all of my output into $string
– Sedric Heidarizarei
Nov 12 at 15:01




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264154%2fhow-to-replace-entire-numbers-in-a-website-to-persian-numbers-via-php%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python