need to replase function
I am have a 2 code
code 1
- Code: Select all
<?php
$TrailingBytes = array ( 0 =>
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
);
function replace_latin_georgian($text)
{
$latin_letters = 'abgdevzTiklmnopJrstufqRySCcZwWxjh';
$georgian_symbols = array(0 => 'ა','ბ','გ','დ','ე','ვ','ზ',
'თ','ი','კ','ლ','მ','ნ','ო','პ','ჟ','რ',
'ს','ტ','უ','ფ','ქ','ღ','ყ','შ','ჩ','ც',
'ძ','წ','ჭ','ხ','ჯ','ჰ');
global $TrailingBytes;
$FirstCharPos=0;
$newtext = '';
for($i=0;$i<strlen($text); $i++)
{
if ($i==$FirstCharPos)
{
$chcode=ord($utf8_string{$i});
$charLength = $TrailingBytes[$chcode]+1;
$FirstCharPos+= $charLength;
if ($charLength == 1) { //Latin character
$oneitem = $text{$i};
$charpos = strpos($latin_letters, $oneitem);
if (!($charpos===false))
$newtext .= $georgian_symbols[$charpos];
else $newtext .= $oneitem;
} else $newtext .= substr($text,$i,$charLength);
}
}
if ($i!=$FirstCharPos)
{
trigger_error("Incorrect UTF8 string", E_USER_ERROR);
return NULL;
}
else return $newtext;
}
?>
code 2
- Code: Select all
<?php
/* Copyright (C) 2003 Tim @ <a href="http://www.forum.ge" target="_blank">www.forum.ge</a> . All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// recoding georgian letters from UTF-8 to Latin;
function geo2latin($text) {
$ge_ltr=array("ა","ბ","გ","დ","ე","ვ","ზ","თ","ი","კ","ლ","მ","ნ","ო","პ","ჟ","რ","ს","ტ","უ","ფ","ქ","ღ","ყ","შ","ჩ","ც","ძ","წ","ჭ","ხ","ჯ","ჰ");
$en_ltr=array("a","b","g","d","e","v","z","T","i","k","l","m","n","o","p","J","r","s","t","u","f","q","R","y","S","C","c","Z","w","W","x","j","h");
for ($i=0; $i<=33; $i++) {
$text = str_replace($ge_ltr[$i], $en_ltr[$i], $text);
}
return $text;
}
?>
what of code script(code 1 or code 2) is fast and why is fast please answer me....
need to more then 20000 simbol convert at time....
Thanks:)


