php实现中文转英文。(数据固定)

/*
 * 函数说明:导航获取中文的英文名称,需配置!!!!!
 *
 * @access  public
 * @param   $chinese  string  中文名称
 * @return  string    英文名称
 */
function translate($chinese = ''){
  $dictionary = array(
    '新闻中心' => 'News',
    '关于我们' => 'About Us',
    '我们的服务' => 'OUR SERVICE',
    '产品中心' => 'PRODUCTS',
    '案例展示' => 'case',
    '新闻动态' => 'news',
    '合作流程' => 'COOPERATION PROCESS',
  );
  $english = $chinese;
  if (array_key_exists($chinese, $dictionary)) {
    $english = $dictionary[$chinese];
  } else $english = '~typenameen~';
  return $english;
}

 


/*
 * 函数说明:导航获取中文的英文名称,需配置!!!!!
 *
 * @access  public
 * @param   $chinese  string  中文名称
 * @return  string    英文名称
 */
function translate($chinese = ''){
  $dictionary = array(
    '新闻中心' => 'News',
    '关于我们' => 'About Us',
    '我们的服务' => 'OUR SERVICE',
    '产品中心' => 'PRODUCTS',
    '案例展示' => 'case',
    '新闻动态' => 'news',
    '合作流程' => 'COOPERATION PROCESS',
  );
  $english = $chinese;
  if (array_key_exists($chinese, $dictionary)) {
    $english = $dictionary[$chinese];
  } else $english = '~typenameen~';
  return $english;
}
posted @ 2020-08-21 10:06  Deer_Lin  阅读(1198)  评论(0)    收藏  举报