当前位置: 首页>>代码示例>>PHP>>正文


PHP tools::cyr2utf方法代码示例

本文整理汇总了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;
开发者ID:Hyyudu,项目名称:Salem_Athlas,代码行数:31,代码来源:hypnomap.php

示例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;
 }
开发者ID:Hyyudu,项目名称:Salem_Athlas,代码行数:51,代码来源:tools.php


注:本文中的tools::cyr2utf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。