Home Backend Development PHP Tutorial 再来个快的_PHP

再来个快的_PHP

Jun 01, 2016 pm 12:36 PM
ar py Pinyin

/**
  拼音码表的生成:
      启动输入法生成器在逆转换选项卡中装入window的拼音输入法并将其保存为文
  本文件(winpy.txt)备用。
  
  下面的代码将拼音码表文件(文本)装入到数组$pymb中,结构为:(拼音,(汉字...))
  码表转换时间较长,应转换后另行保存
*/
$filename = "pymb.txt";
if(file_exists($filename)) {
  $fp = fopen($filename,"r");
  $pymb = unserialize(fread($fp,filesize($filename)));
  fclose($fp);
}else {
  $filename = "winpy.txt";
  $fp = fopen($filename,"r");
  $old = "";
  $ar = array();
  $pymb = array();
  while(! feof($fp)) {
    $buffer = fgets($fp,128);
    sscanf($buffer,"%2s%s",$ch,$py);
    if($ch >= "啊" && ord($py)       $pymb[$ch] = $py;
    }
  }
  fclose($fp);
  $fp = fopen("pymb.txt","w");
  fwrite($fp,serialize($pymb)."\n");
  fclose($fp);
}
?>
  应用例,给文字加上拼音


/**
  应用例,给文字加上拼音。为简化起见,假定全为中文
*/

function get_py($text) {
  global $pymb;
  $i = 0;
  $n = strlen($text);
  $ar = array();
  while($i     $ch = $text[$i++];
    $py = " ";
    if(ord($ch) > 128) {
      $ch .= $text[$i++];
      $py = $pymb[$ch];
    }
    $ar[] = array($ch,$py);
  }
  return $ar;
}

$text = "  拼音码表的生成:
      启动输入法生成器在逆转换选项卡中装入window的拼音输入法并将其保存为文
  本文件(winpy.txt)备用。
  
  下面的代码将拼音码表文件(文本)装入到数组$pymb中,结构为:(拼音,(汉字...))
  码表转换时间较长,应转换后另行保存
";


$ar = get_py($text);
//print_r($ar);

echo "

";
for($i=0;$i   echo "";
}
echo "";
for($i=0;$i   echo "";
}
echo "
".$ar[$i][1]."
".$ar[$i][0]."
";
?>
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

XREAL founder Xu Chi: Apple lets everyone see the future of spatial computing, and we work hard to let everyone see the present of spatial computing. XREAL founder Xu Chi: Apple lets everyone see the future of spatial computing, and we work hard to let everyone see the present of spatial computing. Jun 02, 2024 pm 07:55 PM

XREAL launched a new product - XREALBeamPro at the spatial computing new product launch conference, priced from 1,299 yuan. According to the official introduction, XREALBeamPro is a computing terminal that gradually releases 2D applications into 3D space. Equipped with XREALAR glasses, it will form a "complete consumer-grade AR space computing system" and minimize the migration cost of users from the mobile phone side. In terms of design, XREALBeamPro looks like a smartphone, but it is not a mobile phone product, but a spatial computing terminal equipped with a touch display. It is officially positioned as an “AR spatial computing terminal like a Phone”. At the press conference, XREAL founder and CEO Xu Chi expressed his enthusiasm for BeamPro’s capabilities.

How to build AR/VR applications using PHP How to build AR/VR applications using PHP Jun 11, 2023 pm 07:22 PM

With the development of AR (Augmented Reality) and VR (Virtual Reality), these two technologies have become an important part of innovation and experience. With the popularity of PHP as a network programming language, PHP has become a feasible choice for developing AR/VR applications. This article will introduce how to use PHP to build AR/VR applications. 1. Understand AR and VR technologies Before we start creating AR/VR applications, we need to understand the different technologies and libraries. AR technology allows virtual objects or information to interact with real-world environments. V

Microsoft explores AR/VR patents using microlens arrays for wide-range chief ray angle manipulation Microsoft explores AR/VR patents using microlens arrays for wide-range chief ray angle manipulation Sep 30, 2023 pm 09:29 PM

(Nweon September 26, 2023) Microsoft believes that MicroLED has the characteristics of small size, light weight, high brightness, and high packaging density, and may be particularly suitable for head-mounted devices that require high resolution, small size, and light weight. monitor. In a patent application titled "Microlenses providing wide range chief ray angle manipulation for panel display", Microsoft introduced a microlens that provides wide range chief ray angle manipulation for panel display, and a display system configured with the microlens array. Wherein, each microlens in the array corresponds to a respective pixel of the panel display. Microlenses are configured according to their

How to solve the problem of unable to enter the correct pinyin letters in Ubuntu system How to solve the problem of unable to enter the correct pinyin letters in Ubuntu system Jan 04, 2024 pm 11:10 PM

You cannot type correctly using the Pinyin input method in the Ubuntu system. The words displayed on the input method are not related to the words you want to type. You cannot type the Chinese characters you want to input. This phenomenon often occurs after upgrading the Ubuntu system. How do we solve this problem? The editor below will bring you a solution to the problem that Pinyin cannot be typed correctly in Ubuntu system. Let’s go and see it together! The method is as follows: 1. Press "Ctrl" + "Alt" + "T" on the desktop to open the system terminal: 2. Enter ibus-daemon-drx in the terminal and press Enter: ibus-daemon-drx and then enter pinyin

Mojie Technology debuted at CES for the first time, leading the AR innovation trend! Mojie Technology debuted at CES for the first time, leading the AR innovation trend! Jan 14, 2024 pm 09:06 PM

From January 9th to 12th, more than 4,000 exhibitors gathered at CES, the consumer electronics "Spring Festival Gala". As an innovative company in the field of consumer AR, Mojie Technology participated in CES for the first time, fully demonstrating the strong strength of Chinese AR companies in core devices, complete machine solutions and customized services. At the Mojie booth, the AR glasses based on binocular resin diffraction light waveguide + MicroLED were displayed, which aroused the interest of many visitors, who tried them on and experienced their functions. This AR glasses has many practical features. First, the wearer can view the text content in real time through the glasses lens, which makes reading more convenient. Secondly, the glasses have built-in microphones that can collect voice information and convert it into text in the specified language through the instant translation function.

Christie: dual drive of technology + innovation brings unlimited possibilities Christie: dual drive of technology + innovation brings unlimited possibilities Apr 23, 2024 am 08:10 AM

As a technology company driven by innovation, Christie is able to provide comprehensive solutions, rich industry experience and a complete service network in intelligent audio-visual technology. At this year's InfoCommChina, Christie brought RGB pure laser projectors, 1DLP laser projectors, LED video walls, and content management and processing solutions. At the event site, a large-scale customized outer spherical dome specially designed for astronomical displays became the focus of the scene. Christie named it "Sphere Deep Space", and the Christie M4K25RGB pure laser projector gave it "green vitality" . Mr. Sheng Xiaoqiang, senior technical service manager of the Commercial Business Department in China, said: It is not difficult to realize an outer spherical dome projection, but it can be made smaller and the color

NTT QONOQ Devices unveils Mirza wireless XR glasses for smartphones NTT QONOQ Devices unveils Mirza wireless XR glasses for smartphones Sep 09, 2024 pm 06:30 PM

NTT QONOQ Devices has unveiled the Mirza wireless XR glasses for smartphones, freeing users from needing to wrangle cords. The glasses can display virtual AR content in real-world spaces like Pokemon Go or their phone content on a large virtual displ

Is Apple Vision Pro strong? Foreign media people hesitated after two days of in-depth experience Is Apple Vision Pro strong? Foreign media people hesitated after two days of in-depth experience Feb 02, 2024 am 09:21 AM

This may be the most innovative product released by Apple in 2023, and it may also be the beginning of the next era for Apple. Apple Vision Pro will be officially launched on February 2, local time. What is the experience of using this product that caused a sensation when it was released last year? Recently, foreign technology editor Lance Ulanoff published an in-depth experience diary, which may allow us on the other side of the ocean to understand this product more intuitively and truly. CNMO also compiled Lance’s relevant diaries. Next, the "I" in the article refers to Lance himself. The article has been deleted, but it will not affect reading. Whatever you have heard or read

See all articles