本文整理汇总了PHP中Pinyin函数的典型用法代码示例。如果您正苦于以下问题:PHP Pinyin函数的具体用法?PHP Pinyin怎么用?PHP Pinyin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pinyin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrentCity
public function getCurrentCity($cityList)
{
$List = array();
$isdefault = "";
if ($cityList) {
foreach ($cityList as $city) {
$List[$city["cid"]] = !empty($city["names_en"]) ? strtolower($city["names_en"]) : Pinyin($city["names"]);
$List_zh[strtolower($city["names_en"])] = $city["names"];
$isdefault = $city["isdefault"] ? $city["names_en"] : $isdefault;
}
}
$currentcity = isset($_GET["current_city"]) ? strtolower(trim($_GET["current_city"])) : "";
$currentcity = $currentcity == "" && isset($_COOKIE["current_city"]) ? strtolower(trim($_COOKIE["current_city"])) : $currentcity;
if (empty($currentcity) || !in_array($currentcity, $List)) {
$ip = get_client_ip();
// $ip = "220.173.19.15";
$url = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=' . $ip;
$json = $this->getHttp($url);
$address = json_decode($json, true);
$ipcity = empty($address["city"]) ? "nanning" : strtolower(Pinyin($address["city"]));
$isdefault = in_array($ipcity, $List) ? $ipcity : $isdefault;
$isdefault || ($isdefault = reset($List));
$currentcity = $isdefault;
}
if (!isset($_COOKIE["current_city"]) || $currentcity != $_COOKIE["current_city"]) {
setcookie("current_city", $currentcity, time() + 864000, "/");
}
return array("en" => $currentcity, "zh" => $List_zh[$currentcity], "id" => current(array_keys($List, $currentcity)));
}
示例2: pretreatment
protected function pretreatment()
{
if ($_GET["id"]) {
unset($_POST["model_id"]);
} else {
$_POST["model_id"] = $_POST["modelId"];
}
if (!$_POST["pinyin"]) {
$_POST["pinyin"] = Pinyin($_POST["data"]);
}
//动态新增
if ($_POST["goods_id"]) {
list($fa, $goods_id, $cat_id) = explode("_", $_POST["goods_id"]);
$_POST["source_id"] = $cat_id;
}
if ($_POST["modelAlias"]) {
$theModel = D("DataModel")->getByAlias($_POST["modelAlias"]);
$_POST["model_id"] = $theModel["id"];
}
//检测重复项
if ($_POST["model_id"] && $_POST["source_id"] && $_POST["field_id"] && $_POST["data"]) {
$_map = array("model_id" => $_POST["model_id"], "source_id" => $_POST["source_id"], "field_id" => $_POST["field_id"], "data" => $_POST["data"]);
if (D("DataModelData")->where($_map)->find()) {
$this->error("repeat_item");
exit;
}
}
}
示例3: getname
function getname($name = null)
{
if (empty($name)) {
return Pinyin(I('title'));
} else {
return $name;
}
}
示例4: pretreatment
protected function pretreatment()
{
switch ($this->_method) {
case "post":
case "put":
$_POST["pinyin"] = $_POST["pinyin"] ? $_POST["pinyin"] : Pinyin($_POST["name"]);
break;
}
}
示例5: pretreatment
protected function pretreatment()
{
switch ($this->_method) {
case "post":
case "put":
if (!$_POST["pinyin"]) {
$_POST["pinyin"] = Pinyin($_POST["name"]);
}
break;
}
}
示例6: addChildNode
/**
* 增加子节点
*/
public function addChildNode($sourceData)
{
$parent = $this->find($sourceData["pid"]);
// if(!is_array($sourceData)) {
// $sourceData["name"] = $sourceData;
// }
if (!$parent) {
return false;
}
//rgt = parent rgt -1
/**
* 更新右值
*/
$map = array("rgt" => array("EGT", $parent["rgt"]));
$this->startTrans();
//$data['lft'] = array("lft", "lft+2");
$data['rgt'] = array("exp", "rgt+2");
$rs = $this->where($map)->save($data);
unset($data);
/**
* 更新左值
*/
$map = array("lft" => array("EGT", $parent["rgt"]));
//$data['lft'] = array("lft", "lft+2");
$data['lft'] = array("exp", "lft+2");
$rs = $this->where($map)->save($data);
unset($data);
/**
* 插入新值
*/
$data = array("lft" => $parent["rgt"], "rgt" => $parent["rgt"] + 1);
foreach ($sourceData as $k => $v) {
$data[$k] = $v;
}
$data["pinyin"] = Pinyin($sourceData["name"]);
// echo "<pre>";
// print_r($_POST);
// echo 1;
// print_r($sourceData);
// echo 2;
// print_r($data);
//
$this->create($data);
$rs = $this->add();
// echo $this->getLastSql();exit;
if (!$rs) {
Log::write("SQL Error:" . $this->getLastSql(), Log::SQL);
$this->rollback();
return false;
}
$this->commit();
return $rs;
}
示例7: getname
function getname($name = null)
{
if (empty($name)) {
$py = Pinyin(I('title'));
if (strlen($py) > 8) {
$py = substr($py, 0, 8);
}
return $py;
} else {
return $name;
}
}
示例8: u
/**
* 测试用
*
* @todo 删掉
*/
function u()
{
$this->load->helper('pinyin');
$this->load->model('url_m');
$result = $this->url_m->get_all();
$sug = null;
$i = 0;
foreach ($result as $row) {
$tmp = array($row->name, $row->url, Pinyin($row->name));
$sug[$i] = $tmp;
$i++;
}
//var_dump($sug);
echo json_encode($sug);
}
示例9: run
public function run(&$params)
{
list($bindModelAlias, $data, $pinyin) = $params;
if (!$data["id"]) {
return false;
}
$modelObject = D("DataModel");
$dataModel = $modelObject->getByAlias($bindModelAlias);
if (!$dataModel) {
Log::write("try to insert model data but dataModel not found: " . $bindModelAlias);
return false;
}
$fieldsModelObject = D("DataModelFields");
$tmp = $fieldsModelObject->where("model_id=" . $dataModel["id"])->select();
$modelFields = array();
$modelFieldsAlias = array();
foreach ($tmp as $row) {
$modelFieldsAlias[] = $row["field_name"];
$modelFields[$row["field_name"]] = $row;
}
//数据
foreach ($data as $k => $v) {
if (in_array($k, $modelFieldsAlias)) {
if (isset($data[$k . "_label"])) {
$modelData[$k] = isset($data[$k . "_label"]);
} else {
$modelData[$k] = $v;
}
}
}
$dataModelObject = D("DataModelData");
$dataModelObject->where(array("source_id" => $data["id"], "model_id" => $dataModel["id"]))->delete();
foreach ($modelData as $fieldName => $fieldValue) {
$dataModelObject->add(array("source_id" => $data["id"], "model_id" => $modelFields[$fieldName]["model_id"], "field_id" => $modelFields[$fieldName]["id"], "data" => $fieldValue, "pinyin" => $pinyin ? Pinyin($fieldValue) : "", "deleted" => 0));
}
/*
* source_id
* model_id
* field_id
* data
* pinyin
* deleted
* **/
}
示例10: pretreatment
protected function pretreatment()
{
if (!$_POST["pinyin"]) {
$_POST["pinyin"] = Pinyin($_POST["name"]);
}
if (!$_GET["id"]) {
$_POST["user_id"] = getCurrentUid();
$_POST["dateline"] = CTS;
}
$tmp["rows"] = array();
foreach ($_POST["rows"] as $k => $row) {
if (count($row)) {
$tmp["rows"][] = $row;
} else {
unset($_POST["rows"][$k]);
}
}
$_POST["rows"] = $tmp["rows"];
}
示例11: chr
$_String .= chr(0x80 | $_C >> 12 & 0x3f);
$_String .= chr(0x80 | $_C >> 6 & 0x3f);
$_String .= chr(0x80 | $_C & 0x3f);
}
return iconv('UTF-8', 'GB2312', $_String);
}
function _Array_Combine($_Arr1, $_Arr2)
{
for ($i = 0; $i < count($_Arr1); $i++) {
$_Res[$_Arr1[$i]] = $_Arr2[$i];
}
return $_Res;
}
$city = $_GET['city'];
//echo $city;
$newcity = Pinyin($city, '');
//echo $newcity;
if ($newcity) {
//字符转换(汉字转换拼音,加载字符集转换函数)
//echo $newcity;
$content = file_get_contents("http://www.google.com/ig/api?weather={$newcity}&hl=zh-cn");
//print_r($content);
//$content || die("No such city's data");
$content = mb_convert_encoding($content, 'UTF-8', 'GBK');
$xml = simplexml_load_string($content);
//$date = $xml->weather->forecast_information->forecast_date->attributes();
//$html = $date. "\r\n";
$current = $xml->weather->current_conditions;
if ($current) {
$condition = $current->condition->attributes();
$temp_c = $current->temp_c->attributes();
示例12: cat_list_to_json
/**
* 将商品分类列表转换成符合zTree标准的JSON格式
*/
function cat_list_to_json($cat_list, $selected = 0)
{
$json = '';
foreach ($cat_list as $k => $cat) {
$id = $cat['cat_id'];
$pId = $cat['parent_id'];
$name = $cat['cat_name'];
//$open = true;
$name_pinyin = Pinyin($name, 1, 1) . $name;
$json = sprintf('%s{id: %s, pId: %s, name: "%s", name_pinyin: "%s"},', $json, $id, $pId, $name, $name_pinyin);
}
$json = sprintf('[%s]', $json);
return $json;
}
示例13: cat_list_to_json_string
/**
* 将商品分类列表转换成符合zTree标准的JSON字符串格式
*/
function cat_list_to_json_string($cat_list, $selected = 0)
{
include_once ROOT_PATH . 'includes/Pinyin.php';
$tree = array();
foreach ($cat_list as $k => $cat) {
$id = $cat['cat_id'];
$pId = $cat['parent_id'];
$name = $cat['cat_name'];
//$open = true;
$name_pinyin = Pinyin($name, 'utf-8', 1) . $name;
$node = array("id" => $id, "pId" => $pId, "name" => $name, "name_pinyin" => $name_pinyin);
array_push($tree, $node);
}
return json_encode($tree);
}
示例14: cls_upload
}
$ok = 0;
$c_upload = new cls_upload();
$a_field = new cls_field();
foreach ($coclassitems as $item) {
$coclassnew = $coclasssome;
foreach ($item as $k => $v) {
if (is_array($v)) {
foreach ($v as $a => $b) {
$coclassnew[$k][$a] = $b;
}
} else {
$coclassnew[$k] = $v;
}
}
empty($auto_pinyin) || ($coclassnew['dirname'] = Pinyin($coclassnew['title']));
if (!$coclassnew['title'] || !$coclassnew['dirname']) {
continue;
}
if (preg_match("/[^a-zA-Z_0-9]+/", $coclassnew['dirname'])) {
continue;
}
$coclassnew['dirname'] = strtolower($coclassnew['dirname']);
if (empty($auto_pinyin)) {
if (in_array($coclassnew['dirname'], $enamearr)) {
continue;
}
} else {
$i = 1;
$dirname = $coclassnew['dirname'];
while (in_array($coclassnew['dirname'], $enamearr)) {
示例15: tname
$result2 = $_SGLOBAL['db']->query("select name,username from " . tname('space') . " where uid='{$rs1[$i]}'");
$rs2 = $_SGLOBAL['db']->fetch_array($result2);
if (empty($rs2['name'])) {
$rs2['name'] = $rs2['username'];
}
$result3 = $_SGLOBAL['db']->query("select type from " . tname('spaceinfo') . " where uid='{$rs1[$i]}'");
$rs3 = $_SGLOBAL['db']->fetch_array($result3);
$atfriends[$count++] = array('uid' => $rs1[$i], 'namequery' => $rs2['name'] . ' ' . Pinyin($rs2['name'], 1) . ' ' . $rs1[$i], 'name' => $rs2['name'], 'avatar' => '');
}
//¿¿¿¿¿¿
$query = $_SGLOBAL['db']->query("select uid,name,username from " . tname('space') . " where groupid=3");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
if (empty($value['name'])) {
$value['name'] = $value['username'];
}
$atfriends[$count++] = array('uid' => $value['uid'], 'namequery' => $value['name'] . ' ' . Pinyin($value['name'], 1) . ' ' . $value['uid'], 'name' => $value['name'], 'avatar' => '');
}
$friends = json_encode($atfriends);
$friends = preg_replace("#\\\\u([0-9a-f]+)#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $friends);
$f = fopen($friendurl_w, "w");
fwrite($f, $friends);
fclose($f);
}
//showmessage('bb');//2013Äê3ÔÂ11ÈÕ10:52:45 for find BUG of friend¡¤¡¤ @Ancon£¡
//ȨÏÞÅжÏ
if (empty($_SGLOBAL['supe_uid'])) {
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
ssetcookie('_refer', rawurlencode($_SERVER['REQUEST_URI']));
} else {
ssetcookie('_refer', rawurlencode('cp.php?ac=' . $ac));
}