hehe, I guess you know how I think

2008/4/28 Ahmad Saleh <[EMAIL PROTECTED]>:
> Hi Ammar,
>
> I know that what I wrote is not a way to handle that issue, but also I wont
> to change his code, just fix it.
> the problem in ordering of str_replace, so, when I replace 0 at the first
> time, I will not replace it again.
>
> I know that may be you say now " SHO HAL MOTA7'ALEF ", so, don't say that
> WALA ;)
>
> Cheers
>
> 2008/4/28 alex. asknat <[EMAIL PROTECTED]>:
>
>
>
> >
> >
> > i think you cant use this flow in the code for the function
> replaceNumbers(),  it will not work at all ... it will display bugs all the
> time ... you have to split the characters of the string and import it in the
> function char by char .. you have to call the function on  every charachter
> seperatly then merge them to get th full string you need ... the output will
> be correct.
> >
> >
> > the other function that uses array i think it will do the job too,
> >
> >
> > iskandar m.
> >
> >
> > ________________________________
>
> > > Date: Mon, 28 Apr 2008 12:48:28 +0300
> > > From: [EMAIL PROTECTED]
> > > To: [email protected]
> > > Subject: [JoPHP] Re: what is the problem with this code
> >
> >
> >
> > >
> > > There's a serious flaw in the code, let's take this $str as an
> > > example, and follow your function:
> > > "456"
> > >
> > > When we call replaceNumbers(), the following happens
> > >
> > > 4 is replaced by "&#x0664;" the string becomes "&#x0664;56"
> > > then 5 is replaced by "&#x0665;" the string becomes "&#x0664;&#x0665;6"
> > > now the real problem happens! Every instance of 6 is replaced by
> > > "&#x0666;" the result is gonna be very messy. Even Ahmad's version is
> > > flawed, because when you replace a 0, it will ruin all the sequences,
> > > instead use the following. I don't recommend the last two, they are
> > > just provided as examples to save you a bit of typing, but they are
> > > horrible in terms of performance or even simple coding rules.
> > >
> > > function replaceNumbers($str){
> > > $arNum = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
> > > $inNum = array("&#x0660;", "&#x0661;", "&#x0662;", "&#x0663;",
> > > "&#x0664;",
> > > "&#x0665;", "&#x0666;", "&#x0667;",
> > > "&#x0668;", "&#x0669;");
> > >
> > > return str_replace($arNum, $inNum, $str);
> > > }
> > >
> > >
> > > function replaceNumbersBaby($str) {
> > > array_walk(range(0,9), create_function('$num',
> > > '$GLOBALS["inNum"][] = "&#x660".$num.";";') );
> > > return str_replace(range(0,9), $GLOBALS["inNum"], $str);
> > > }
> > >
> > > function replaceNumbersRegex($str){
> > > return preg_replace("/(\d)/", '&#x066$1;', $str);
> > > }
> > >
> > >
> > > 2008/4/28 Ibrahim Y <[EMAIL PROTECTED]>:
> > > > Hello all,
> > > >
> > > > let's have this piece of code
> > > >
> > > > > <?php
> > > > > function replaceNumbers($str){
> > > > > $str = str_replace("0" , "&#x0660;" , $str );
> > > > > $str = str_replace("1" , "&#x0661;" , $str );
> > > > > $str = str_replace("2" , "&#x0662;" , $str );
> > > > > $str = str_replace("3" , "&#x0663;" , $str );
> > > > > $str = str_replace("4" , "&#x0664;" , $str );
> > > > > $str = str_replace("5" , "&#x0665;" , $str );
> > > > > $str = str_replace("6" , "&#x0666;" , $str );
> > > > > $str = str_replace("7" , "&#x0667;" , $str );
> > > > > $str = str_replace("8" , "&#x0668;" , $str );
> > > > > $str = str_replace("9" , "&#x0669;" , $str );
> > > > > $str = str_replace("Wednesday" , "الأربعاء" , $str );
> > > > > $str = str_replace("July" , "تموز" , $str );
> > > > > return $str;
> > > > > }
> > > > >
> > > > > echo replaceNumbers("Wednesday, 07 July 2008");
> > > > > ?>
> > > > >
> > > >
> > > > The output when invoking the function as follow:
> > > >
> > > > when removing the line in Bold is ( الأربعاء, ٠٧ تموز ٢٠٠٨ ).
> > > > when the line is there the output is (الأربعاء, �٦٦0;٧ تموز
> > > > �٦٦2;�٦٦0;�٦٦0;٨).what I want is to replace English numbers into
> > > > Arabic(hindi) before I display them on the page, is there any better
> way to
> > > > replace numbers into Arabic.
> > > >
> > > > Ibrahim
> > > >
> > > >
> > > > >
> > > >
> > >
> > >
> >
>
>
>
> --
> Ahmad Fathi Saleh
> http://ahmad.jopdc.com
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Jordan PHP Users Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/JoPHP
http://Jolug.org/
-~----------~----~----~----~------~----~------~--~---

Reply via email to