Поправил названия классов
This commit is contained in:
parent
c8958cbee0
commit
8a8e42d73d
21 changed files with 64 additions and 86 deletions
|
|
@ -1,37 +1,53 @@
|
|||
<?php
|
||||
|
||||
// from creole
|
||||
function strToArray($str)
|
||||
{
|
||||
$str = substr($str, 1, -1); // remove { }
|
||||
$res = array();
|
||||
|
||||
$subarr = array();
|
||||
$in_subarr = 0;
|
||||
|
||||
$toks = explode(',', $str);
|
||||
foreach($toks as $tok) {
|
||||
if ($in_subarr > 0) { // already in sub-array?
|
||||
$subarr[$in_subarr][] = $tok;
|
||||
if ('}' === substr($tok, -1, 1)) { // check to see if we just added last component
|
||||
$res[] = $this->strToArray(implode(',', $subarr[$in_subarr]));
|
||||
$in_subarr--;
|
||||
}
|
||||
} elseif ($tok{0} === '{') { // we're inside a new sub-array
|
||||
if ('}' !== substr($tok, -1, 1)) {
|
||||
$in_subarr++;
|
||||
// if sub-array has more than one element
|
||||
$subarr[$in_subarr] = array();
|
||||
$subarr[$in_subarr][] = $tok;
|
||||
} else {
|
||||
$res[] = $this->strToArray($tok);
|
||||
}
|
||||
} else { // not sub-array
|
||||
$val = trim($tok, '"'); // remove " (surrounding strings)
|
||||
// perform type castng here?
|
||||
$res[] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
class Tools_String {
|
||||
// from creole
|
||||
static function strToArray($str)
|
||||
{
|
||||
$str = substr($str, 1, -1); // remove { }
|
||||
$res = array();
|
||||
|
||||
$subarr = array();
|
||||
$in_subarr = 0;
|
||||
|
||||
$toks = explode(',', $str);
|
||||
foreach($toks as $tok) {
|
||||
if ($in_subarr > 0) { // already in sub-array?
|
||||
$subarr[$in_subarr][] = $tok;
|
||||
if ('}' === substr($tok, -1, 1)) { // check to see if we just added last component
|
||||
$res[] = $this->strToArray(implode(',', $subarr[$in_subarr]));
|
||||
$in_subarr--;
|
||||
}
|
||||
} elseif ($tok{0} === '{') { // we're inside a new sub-array
|
||||
if ('}' !== substr($tok, -1, 1)) {
|
||||
$in_subarr++;
|
||||
// if sub-array has more than one element
|
||||
$subarr[$in_subarr] = array();
|
||||
$subarr[$in_subarr][] = $tok;
|
||||
} else {
|
||||
$res[] = $this->strToArray($tok);
|
||||
}
|
||||
} else { // not sub-array
|
||||
$val = trim($tok, '"'); // remove " (surrounding strings)
|
||||
// perform type castng here?
|
||||
$res[] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
static function translit($st) {
|
||||
$st = strtr($st,"абвгдеёзийклмнопрстуфхъыэ !№", "abvgdeeziyklmnoprstufh_ie__#");
|
||||
$st = strtr($st,"АБВГДЕЁЗИЙКЛМНОПРСТУФХЪЫЭ", "ABVGDEEZIYKLMNOPRSTUFH_IE");
|
||||
$st = strtr($st, array(
|
||||
"ж"=>"zh", "ц"=>"ts", "ч"=>"ch", "ш"=>"sh",
|
||||
"щ"=>"shch","ь"=>"", "ю"=>"yu", "я"=>"ya",
|
||||
"Ж"=>"ZH", "Ц"=>"TS", "Ч"=>"CH", "Ш"=>"SH",
|
||||
"Щ"=>"SHCH","Ь"=>"", "Ю"=>"YU", "Я"=>"YA",
|
||||
"ї"=>"i", "Ї"=>"Yi", "є"=>"ie", "Є"=>"Ye"
|
||||
));
|
||||
return $st;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue