本文整理汇总了PHP中tools::cyr2utf方法的典型用法代码示例。如果您正苦于以下问题:PHP tools::cyr2utf方法的具体用法?PHP tools::cyr2utf怎么用?PHP tools::cyr2utf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools
的用法示例。
在下文中一共展示了tools::cyr2utf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: file_get_contents
$template = file_get_contents('templates/output_start.htm') . file_get_contents('templates/hypnomap.htm') . file_get_contents('templates/output_end.htm');
//echo $template;
$patient = $_SESSION['patient'];
//print_r($patient);
//Проверка - Салем или нет
if (strtolower($patient['city']) == 'salem') {
$template = str_replace(array('{ifsalem}', '{endifsalem}'), array('', ''), $template);
} else {
$template = preg_replace('~\\{ifsalem\\}.*?\\{endifsalem\\}~', '', $template);
}
$repl = array('character_name' => $_SESSION['patient']['character_name'], 'cityname' => $cities[strtolower($patient['city'])]);
$tmpl = $year == '1945' ? 'location_1945.htm' : 'location.htm';
$location_stub = file_get_contents('templates/' . $tmpl);
foreach ($mapping[strtolower($patient['city'])] as $item) {
$rus_loc = $locations[$item];
$rus_loc = tools::cyr2utf(mb_strtolower(tools::utf2cyr($rus_loc)));
if (!$item || mb_strpos($patient['locs_absent'], $rus_loc) !== false) {
$txt = "\n\t\t<div class=location></div>\n";
} else {
$txt = $location_stub;
foreach (array('location' => $item, 'location_name' => $locations[$item], 'trigger_word' => $trigger_pages[$patient['psychotype']][$item], 'trigger_page' => 'common/' . $trigger_pages['trigger_page'][$item]) as $k => $v) {
$txt = str_replace('{' . $k . '}', $v, $txt);
}
}
$loc_text .= $txt;
}
$repl['locations'] = $loc_text;
foreach ($repl as $k => $v) {
$template = str_replace('{' . $k . '}', $v, $template);
}
echo $template;
示例2: read_csv
public static function read_csv($filename, $assoc_field = '', $needed_fields = array(), $use_ciphered = false)
{
$tempfile = '~tmp.dat';
if ($use_ciphered) {
$ciphered_file = str_replace('.csv', '.dat', $filename);
if (file_exists($filename)) {
file_put_contents($ciphered_file, base64_encode(file_get_contents($filename)));
}
$text = file_get_contents($ciphered_file);
file_put_contents($tempfile, base64_decode($text));
$f = fopen($tempfile, 'r');
} else {
$f = fopen($filename, 'r');
}
while ($row = fgetcsv($f, 0, ';')) {
$row = tools::cyr2utf($row);
if (!isset($fields)) {
$fields = $row;
$last = array_search('—', $fields);
if ($last) {
$fields = array_splice($fields, 0, $last);
}
} else {
$row = array_splice($row, 0, count($fields));
if ($row) {
while (count($row) < count($fields)) {
$row[] = '';
}
// Делаем ассоциативный массив по полям
$arr = array_combine($fields, $row);
// Оставляем только нужные поля
if ($needed_fields) {
foreach ($arr as $key => $val) {
if (!in_array($key, $needed_fields)) {
unset($arr[$key]);
}
}
}
if ($assoc_field) {
$out[strtolower($arr[$assoc_field])] = $arr;
} else {
$out[] = $arr;
}
}
}
}
if (file_exists($tempfile)) {
@unlink($tempfile);
}
return $out;
}