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 "٤" the string becomes "٤56" > > > then 5 is replaced by "٥" the string becomes "٤٥6" > > > now the real problem happens! Every instance of 6 is replaced by > > > "٦" 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("٠", "١", "٢", "٣", > > > "٤", > > > "٥", "٦", "٧", > > > "٨", "٩"); > > > > > > return str_replace($arNum, $inNum, $str); > > > } > > > > > > > > > function replaceNumbersBaby($str) { > > > array_walk(range(0,9), create_function('$num', > > > '$GLOBALS["inNum"][] = "٠".$num.";";') ); > > > return str_replace(range(0,9), $GLOBALS["inNum"], $str); > > > } > > > > > > function replaceNumbersRegex($str){ > > > return preg_replace("/(\d)/", 'f$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" , "٠" , $str ); > > > > > $str = str_replace("1" , "١" , $str ); > > > > > $str = str_replace("2" , "٢" , $str ); > > > > > $str = str_replace("3" , "٣" , $str ); > > > > > $str = str_replace("4" , "٤" , $str ); > > > > > $str = str_replace("5" , "٥" , $str ); > > > > > $str = str_replace("6" , "٦" , $str ); > > > > > $str = str_replace("7" , "٧" , $str ); > > > > > $str = str_replace("8" , "٨" , $str ); > > > > > $str = str_replace("9" , "٩" , $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/ -~----------~----~----~----~------~----~------~--~---
