本文整理汇总了PHP中GetPinyin函数的典型用法代码示例。如果您正苦于以下问题:PHP GetPinyin函数的具体用法?PHP GetPinyin怎么用?PHP GetPinyin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetPinyin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: matchPinyin
function matchPinyin($keyword)
{
global $dsql;
$sql = "select kindname as matchname from #@__destinations where isopen=1";
$res = $dsql->getAll($sql);
$str = '';
foreach ($res as $row) {
if (strlen($keyword) == 1) {
$pinyin = GetPinyin($row['matchname']);
// 获取拼音
if (strpos($pinyin, $keyword) !== false) {
if (substr($pinyin, 0, 1) == $keyword) {
$str .= $row['matchname'] . ",";
}
}
} else {
$pinyin = GetPinyin($row['matchname'], 1);
// 获取拼音
if (strpos($pinyin, $keyword) !== false) {
$str .= $row['matchname'] . ",";
}
}
}
$str = substr($str, 0, strlen($str) - 1);
return $str;
}
示例2: normalize
public static function normalize($slug, $hashtag = false)
{
$slug = GetPinyin($slug);
$slug = preg_replace('@/+@', '/', $slug);
$slug = trim($slug, '/');
$slug = phutil_utf8_strtolower($slug);
$ban = "\\x00-\\x19" . "#%&+=?" . " " . "\\\\" . "<>{}\\[\\]" . "'" . '"';
// In hashtag mode (used for Project hashtags), ban additional characters
// which cause parsing problems.
if ($hashtag) {
$ban .= '`~!@$^*,:;(|)';
}
$slug = preg_replace('([' . $ban . ']+)', '_', $slug);
$slug = preg_replace('@_+@', '_', $slug);
$parts = explode('/', $slug);
// Remove leading and trailing underscores from each component, if the
// component has not been reduced to a single underscore. For example, "a?"
// converts to "a", but "??" converts to "_".
foreach ($parts as $key => $part) {
if ($part != '_') {
$parts[$key] = trim($part, '_');
}
}
$slug = implode('/', $parts);
// Specifically rewrite these slugs. It's OK to have a slug like "a..b",
// but not a slug which is only "..".
// NOTE: These are explicitly not pht()'d, because they should be stable
// across languages.
$replace = array('.' => 'dot', '..' => 'dotdot');
foreach ($replace as $pattern => $replacement) {
$pattern = preg_quote($pattern, '@');
$slug = preg_replace('@(^|/)' . $pattern . '(\\z|/)@', '\\1' . $replacement . '\\2', $slug);
}
return $slug . '/';
}
示例3: normalize
public static function normalize($slug)
{
$slug = GetPinyin($slug);
$slug = preg_replace('@/+@', '/', $slug);
$slug = trim($slug, '/');
$slug = phutil_utf8_strtolower($slug);
$slug = preg_replace("@[\\x00-\\x19#%&+=\\\\?<> ]+@", '_', $slug);
$slug = preg_replace('@_+@', '_', $slug);
// Remove leading and trailing underscores from each component, if the
// component has not been reduced to a single underscore. For example, "a?"
// converts to "a", but "??" converts to "_".
$parts = explode('/', $slug);
foreach ($parts as $key => $part) {
if ($part != '_') {
$parts[$key] = trim($part, '_');
}
}
$slug = implode('/', $parts);
// Specifically rewrite these slugs. It's OK to have a slug like "a..b",
// but not a slug which is only "..".
// NOTE: These are explicitly not pht()'d, because they should be stable
// across languages.
$replace = array('.' => 'dot', '..' => 'dotdot');
foreach ($replace as $pattern => $replacement) {
$pattern = preg_quote($pattern, '@');
$slug = preg_replace('@(^|/)' . $pattern . '(\\z|/)@', '\\1' . $replacement . '\\2', $slug);
}
return $slug . '/';
}
示例4: header_city
public function header_city()
{
//echo C('DB_PREFIX');//__PREFIX__
$city1 = new \Think\Model();
$prefix = C('DB_PREFIX');
$sql = "select r.* from {$prefix}store_shipping_region as ssr left join {$prefix}region as r on ssr.city=r.region_id where ssr.city>0 group by ssr.city";
$row_region = $city1->query($sql);
foreach ($row_region as $v) {
$zimu = GetPinyin($v['region_name'], 1);
//var_dump($zimu);
$zimu = strtoupper(substr($zimu, 0, 1));
$zimu_city[$zimu][] = array('region_id' => $v['region_id'], 'region_name' => $v['region_name']);
}
return $zimu_city;
//var_dump($zimu_city);
}
示例5: normalize
public static function normalize($slug)
{
$slug = GetPinyin($slug);
$slug = preg_replace('@/+@', '/', $slug);
$slug = trim($slug, '/');
$slug = phutil_utf8_strtolower($slug);
$slug = preg_replace("@[\\x00-\\x19#%&+=\\\\?<> ]+@", '_', $slug);
$slug = preg_replace('@_+@', '_', $slug);
$slug = trim($slug, '_');
// Specifically rewrite these slugs. It's OK to have a slug like "a..b",
// but not a slug which is only "..".
// NOTE: These are explicitly not pht()'d, because they should be stable
// across languages.
$replace = array('.' => 'dot', '..' => 'dotdot');
foreach ($replace as $pattern => $replacement) {
$pattern = preg_quote($pattern, '@');
$slug = preg_replace('@(^|/)' . $pattern . '(\\z|/)@', '\\1' . $replacement . '\\2', $slug);
}
return $slug . '/';
}
示例6: values
//将作者插入文档关键词中
$zuozheurl = $zuozhedir . ".html";
if ($co_autokeytype == 1 || ($co_autokeytype = 3)) {
$row = $dsql->GetOne("SELECT `keyword` FROM `#@__keywords` WHERE `keyword`='{$zuozhe}'");
if (!$row && strlen($zuozhe) > 2) {
$keyword_in_query = "insert into `#@__keywords` (`keyword`, `rank`, `sta`, `rpurl`) values('{$zuozhe}','30','1','{$zuozheurl}')";
$dsql->ExecuteNoneQuery($keyword_in_query);
}
}
}
}
//如果新增的栏目隶属于作品集,插入文档关键词中
if ($reid == '45') {
//变更作者URL格式
if ($zuozherule != '' && $zuozherule != "[拼音]") {
$pydir = GetPinyin(stripslashes($title), 1);
$typepinyin = substr($typedir, 1);
$typedir = str_replace('[拼音首字母]', $pydir, str_replace('[ID]', $bookid, str_replace('[拼音]', $typepinyin, $zuozherule)));
$typedir = preg_replace("#\\/{1,}#", "/", $typedir);
//检查是否有重名的小说目录,如果有则目录拼音后自动添加数字区别
$typedirrow = $dsql->GetOne("SELECT `typedir` FROM `#@__arctype` WHERE `typedir`='/{$typedir}'");
if ($typedirrow) {
for ($ti = 1; $ti < 100; $ti++) {
$typedirsql = "SELECT `typedir` FROM `#@__arctype` WHERE `typedir`='/" . $typedir . $ti . "'";
$typedirrow = $dsql->GetOne($typedirsql);
if (!$typedirrow) {
$typedir = $typedir . $ti;
break;
}
}
}
示例7: import
/**
* 导入数据 已废弃
*/
function import()
{
exit;
$names = array('顺丰', '圆通', '中通', '申通', '汇通', '韵达', '天天', '宅急送', 'EMS');
$model = M(CONTROLLER_NAME);
foreach ($names as $name) {
$data['name'] = $name;
$data['code'] = GetPinyin($name);
$model->add($data);
}
echo 'ok';
}
示例8: GetPinyin
<?php
//示例
echo GetPinyin("魍魉");
/**
* 汉字转拼音
* @param string $str 待转换的字符串
* @param string $charset 字符串编码
* @param bool $ishead 是否只提取首字母
* @return string 返回结果
*/
function GetPinyin($str, $charset = "utf-8", $ishead = 0)
{
$restr = '';
$str = trim($str);
if ($charset == "utf-8") {
$str = iconv("utf-8", "gb2312", $str);
}
$slen = strlen($str);
$pinyins = array();
if ($slen < 2) {
return $str;
}
$fp = fopen('pinyin.dat', 'r');
while (!feof($fp)) {
$line = trim(fgets($fp));
$pinyins[$line[0] . $line[1]] = substr($line, 3, strlen($line) - 3);
}
fclose($fp);
for ($i = 0; $i < $slen; $i++) {
if (ord($str[$i]) > 0x80) {
示例9: insert_mycity
function insert_mycity($arr)
{
global $ecs, $db, $smarty;
$need_cache = $smarty->caching;
$need_compile = $smarty->force_compile;
//$sqlr="select * from ". $GLOBALS['ecs']->table('region') ." where region_type =2";
$sql = "select r.* from " . $ecs->table('store_shipping_region') . " as ssr left join " . $ecs->table('region') . " as r on ssr.city=r.region_id where ssr.city>0 group by ssr.city";
$res_region = $db->query($sql);
$zimu_city = array();
while ($row_region = $db->fetchRow($res_region)) {
$zimu = GetPinyin($row_region['region_name'], 1);
$zimu = strtoupper(substr($zimu, 0, 1));
$zimu_city[$zimu][$row_region['region_id']] = array('region_id' => $row_region['region_id'], 'region_name' => $row_region['region_name'], 'level' => 2);
}
$smarty->assign('zimu_city', $zimu_city);
$smarty->assign('nowcityname', $db->getOne("select region_name from " . $ecs->table("region") . " where region_id=" . $_REQUEST['city']));
$val = $smarty->fetch('library/header_city.lbi');
$smarty->caching = $need_cache;
$smarty->force_compile = $need_compile;
return $val;
}
示例10: GetBookUrl
/**
* 获得图书的URL
*
* @param string $bid 书籍ID
* @param string $title 标题
* @param string $gdir
* @return string
*/
function GetBookUrl($bid, $title, $gdir = 0)
{
global $cfg_cmspath;
$bookurl = $gdir == 1 ? "{$cfg_cmspath}/book/" . DedeID2Dir($bid) : "{$cfg_cmspath}/book/" . DedeID2Dir($bid) . '/' . GetPinyin($title) . '-' . $bid . '.html';
return $bookurl;
}
示例11: foreach
foreach ($bianjiqifieldsarr as $key => $val) {
$field = $val['field'];
$dataother[$field] = $_POST[$field];
}
}
//查询此模型编辑器的字段 end
if ($_POST['self'] && is_array($_POST['self'])) {
foreach ($_POST['self'] as $field => $val) {
${$field} = save($val);
$dataother[$field] = ${$field};
}
}
//zhaoyanmin 其他表 end
$remote && remote($body);
!$remote && $autopic && remote($body, true);
empty($customlink) && ($customlink = GetPinyin($title));
if (empty($aid)) {
$userid = $admin->uid;
$hits = $digg = $comments = 0;
$filename = "";
//$DreamCMS->db->get_var("SELECT `id` FROM `#DC@__article` where `customlink` ='$customlink'") && alert('该自定链接已经存在!请另选一个');
//$DreamCMS->db->get_var("SELECT `id` FROM `#DC@__article` where `title` = '$title'") && alert('该标题的文章已经存在!请检查是否重复');
$DreamCMS->db->insert('article', compact('cid', 'title', 'customlink', 'url', 'filename', 'source', 'author', 'userid', 'postype', 'keywords', 'tags', 'description', 'pic', 'pubdate', 'hits', 'digg', 'comments', 'type', 'visible'));
$aid = $DreamCMS->db->insert_id;
//zhaoyanmin start
//添加其他表 start
if ($model['table']) {
$dataother['aid'] = $aid;
$DreamCMS->db->insert($model['table'], $dataother);
}
//添加其他表 end
示例12: define
/**
* ECSHOP 首页文件
* ============================================================================
* * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: liubo $
* $Id: index.php 17217 2011-01-19 06:29:08Z liubo $
*/
define('IN_ECS', true);
require dirname(__FILE__) . '/includes/init.php';
if ((DEBUG_MODE & 2) != 2) {
$smarty->caching = true;
}
$sql = "select r.* from " . $ecs->table('store_shipping_region') . " as ssr left join " . $ecs->table('region') . " as r on ssr.city=r.region_id where ssr.city>0 group by ssr.city";
$res_region = $db->query($sql);
$zimu_city = array();
while ($row_region = $db->fetchRow($res_region)) {
$zimu = GetPinyin($row_region['region_name'], 1);
$zimu = strtoupper(substr($zimu, 0, 1));
$zimu_city[$zimu][] = array('region_id' => $row_region['region_id'], 'region_name' => $row_region['region_name']);
}
$zimu_info = array_keys($zimu_city);
sort($zimu_info);
$smarty->assign('zimu_info', $zimu_info);
ksort($zimu_city);
$smarty->assign('zimu_city', $zimu_city);
$smarty->display('city.dwt');
示例13: lib_gethotellist
//.........这里部分代码省略.........
$sql = "select {$basefield},b.isding,b.isjian,b.istejia from #@__hotel a left join #@__kindorderlist as b on (a.id=b.aid and b.classid='{$sonid}' and b.typeid='2') where " . $where . " and (a.ishidden='0' or a.ishidden is null){$orderby} limit {$limit},{$row}";
} else {
if ($type == 'rank') {
if (isset($refObj->Fields['sonid'])) {
$sonid = $refObj->Fields['sonid'];
$sql = "select a.*,b.hotelrank from #@__hotel a left join #@__hotel_rank b on a.hotelrankid=b.aid where a.webid=0 and a.hotelrankid={$sonid} and a.ishidden='0' order by a.modtime desc,a.addtime desc limit {$limit},{$row}";
} else {
return '';
}
} else {
if ($type == 'rankhot') {
$sql = "select a.*,b.hotelrank from #@__hotel a left join #@__hotel_rank b on a.hotelrankid=b.aid where a.ishidden='0' order by a.shownum desc limit {$limit},{$row}";
} else {
if ($type == 'theme') {
$themeid = $refObj->Fields['themeid'];
if (empty($themeid)) {
return '';
}
$sql = "select a.*,b.hotelrank,a.price as price from #@__hotel a left join #@__hotel_rank b on (a.hotelrankid=b.aid and a.webid=b.webid) where a.ishidden='0' and FIND_IN_SET({$themeid},a.themelist) order by a.modtime desc,a.addtime desc,a.shownum desc limit {$limit},{$row}";
} else {
if ($type == 'top') {
if ($flag == 'recommend') {
$sql = "select {$basefield},b.displayorder,b.isding,b.isjian,b.istejia,a.ishidden,a.price from #@__hotel a left join #@__allorderlist b on(a.id=b.aid and b.typeid=2) where a.ishidden='0' order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}";
} else {
if ($flag == 'special') {
$sql = "select {$basefield},b.displayorder,b.isding,b.isjian,b.istejia as istehui,a.ishidden from #@__hotel a left join #@__allorderlist b on(a.id=b.aid and b.typeid=2) order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}";
} else {
if ($flag == 'hot') {
$sql = "select a.*,b.hotelrank,a.price as price from #@__hotel a left join #@__hotel_rank b on (a.hotelrankid=b.aid and a.webid=b.webid) where a.ishidden='0' group by a.title order by a.shownum desc,a.modtime desc,a.addtime desc limit {$limit},{$row}";
} else {
if ($flag == 'relative') {
$kindlist = $refObj->Fields['kindlist'];
$maxkindid = array_remove_value($kindlist);
//最后一级.
$maxkindid = empty($maxkindid) ? $GLOBALS['dest_id'] : $maxkindid;
$maxkindid = empty($maxkindid) ? 0 : $maxkindid;
$where = " FIND_IN_SET({$maxkindid},a.kindlist) ";
//排序顺序:置顶+tag关联》排序+ tag关联》最新更新+tag关联
$sql = "select a.*,b.hotelrank from #@__hotel a left join #@__hotel_rank b on (a.hotelrankid=b.aid and a.webid=b.webid) where a.ishidden='0' and {$where} order by a.modtime desc,a.addtime desc limit {$limit},{$row} ";
} else {
return '';
}
}
}
}
}
}
}
}
}
$dsql->SetQuery($sql);
$dsql->Execute();
$ctp = new STTagParse();
$ctp->SetNameSpace("field", "[", "]");
$ctp->LoadSource($innertext);
$GLOBALS['autoindex'] = 0;
while ($row = $dsql->GetArray()) {
$GLOBALS['autoindex']++;
$urlname = GetPinyin($row['kindname']);
$flag != "channel" ? $webroot = GetWebURLByWebid($row['webid']) : "";
$row['url'] = GetWebURLByWebid($row['webid']) . "/hotels/show_{$row['aid']}.html";
$row['title'] = $row['title'];
//$row['price']=empty($row['price'])?GetHotelMinPrice($row['webid'],$row['aid']):$row['price'];
$row['kindname'] = getHotelKindCity2($row['kindlist']);
$row['commentnum'] = Helper_Archive::getCommentNum($row['id'], 2);
//评论次数
$row['sellnum'] = Helper_Archive::getSellNum($row['id'], 2) + $row['bookcount'];
//销售数量
$row['satisfyscore'] = Helper_Archive::getSatisfyScore($row['id'], 2);
//满意度
$row['listingprice'] = getHotelSellPrice2($row['id']);
//挂牌价
$row['price'] = Helper_Archive::getHotelMinPrice($row['id']);
$row['sellprice'] = empty($row['price']) ? '0' : $row['price'];
$row['price2'] = empty($row['price']) ? '电询' : '¥' . $row['price'] . '起';
//样式2
$row['price3'] = empty($row['price']) ? '电询' : '<strong>¥' . $row['price'] . '</strong><span>起</span>';
$row['price4'] = empty($row['price']) ? '电询' : '<span>¥</span><strong>' . $row['price'] . '</strong><i>起</i>';
//目的地页面用
$row['price'] = empty($row['price']) ? '<span class="rmb_1">电询</span>' : "<span class='rmb_1'>¥</span>" . $row['price'] . "<span>起</span>";
$litpic = getUploadFileUrl($row['litpic']);
$row['lit240'] = getUploadFileUrl(str_replace('litimg', 'lit240', $row['litpic']));
$row['lit160'] = getUploadFileUrl(str_replace('litimg', 'lit160', $row['litpic']));
$row['litpic'] = $litpic;
$row['typeurl'] = $GLOBALS['cfg_cmsurl'] . "/hotels/{$urlname}_{$row['id']}.html";
foreach ($ctp->CTags as $tagid => $ctag) {
if ($ctag->GetName() == 'array') {
$ctp->Assign($tagid, $row);
} else {
if (!empty($row[$ctag->GetName()])) {
$ctp->Assign($tagid, $row[$ctag->GetName()]);
} else {
$ctp->Assign($tagid, '');
}
}
}
$revalue .= $ctp->GetResult();
}
return $revalue;
}
示例14: while
if (!$typedirrow) {
$typedir = $typedir . $ti;
break;
}
}
}
$typedir = "/" . $typedir;
$dsql->ExecuteNoneQuery("UPDATE `#@__arctype` SET `typedir`='{$typedir}' WHERE id='{$iddir}' ");
}
}
if ($oldzuozherule != $newzuozherule && $czuozheurl == 'Y') {
$dsql->SetQuery("SELECT * FROM `#@__arctype` where reid=45");
$dsql->Execute();
while ($row = $dsql->GetArray()) {
$pinyindir = GetPinyin(stripslashes($row['typename']));
$pydir = GetPinyin(stripslashes($row['typename']), 1);
$iddir = $row['id'];
$typedir = str_replace('[拼音首字母]', $pydir, str_replace('[ID]', $iddir, str_replace('[拼音]', $pinyindir, $newzuozherule)));
$typedir = preg_replace("#\\/{1,}#", "/", $typedir);
//检查是否有重名的小说目录,如果有则目录拼音后自动添加数字区别
$typedirrow = $dsql->GetOne("SELECT `typedir` FROM `#@__arctype` WHERE `typedir`='/{$typedir}'");
if ($typedirrow) {
for ($ti = 1; $ti < 100; $ti++) {
$typedirsql = "SELECT `typedir` FROM `#@__arctype` WHERE `typedir`='/" . $typedir . $ti . "'";
$typedirrow = $dsql->GetOne($typedirsql);
if (!$typedirrow) {
$typedir = $typedir . $ti;
break;
}
}
}
示例15: switch
switch ($attrib) {
case "list":
$tpl['list'] ? $tpl_list = $tpl['list'] : alert("请选择栏目模板");
$tpl['content'] ? $tpl_contents = $tpl['content'] : alert("请选择内容模板");
break;
case "channel":
$tpl['channel'] ? $tpl_index = $tpl['channel'] : alert("请选择频道封面模板");
break;
case "page":
$tpl['page'] ? $tpl_index = $tpl['page'] : alert("请选择栏目模板");
empty($dir) && ($dir = GetPinyin($name));
break;
default:
alert("怪事!你怎么跑这里来了!!\n你想干嘛??");
}
$pinyin == 1 && ($dir = GetPinyin($name));
$attrib == 'page' && ($issend = '0');
//zhaoyanmin 栏目目录 start
$mulusql = empty($cid) ? '' : " AND `id` !='{$cid}' ";
$mulutong = $DreamCMS->db->get_var("SELECT `dir` FROM `#DC@__catalog` where `dir` ='{$dir}' " . $mulusql);
if ($mulutong) {
//查询上级栏目
$precatalog = $DreamCMS->db->get_row("SELECT `dir` FROM `#DC@__catalog` where `id` ='{$rootid}'", ARRAY_A);
$dir = $precatalog['dir'] . $dir;
}
//zhaoyanmin 栏目目录 end
if (empty($cid)) {
$topid = intval($topid);
//zhaoyanmin
// $DreamCMS->db->insert('catalog', compact('rootid','order','name','password','keywords','description','dir','url','icon','tpl_index','tpl_list','tpl_contents','attrib','isexamine','ishidden','issend'));
//$DreamCMS->db->get_var("SELECT `dir` FROM `#DC@__catalog` where `dir` ='$dir'") && alert('该栏目别名/目录已经存在!请另选一个');