Let's get a quick _php tutorial.

Source: Internet
Author: User
/**
Phonetic Code table Generation:
Start the Input Method Builder in the Invert tab, mount the phonetic Input Method for window and save it as a text
This document (Winpy.txt) is reserved.

The following code loads the Phonetic Code table file (text) into the array $pymb, with the structure: (Pinyin, (Kanji ...))
The Code table conversion time is longer, should be converted and saved separately
*/
$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 >= "Ah" && Ord ($py) < 128) {
$PYMB [$ch] = $py;
}
}
Fclose ($FP);
$fp = fopen ("Pymb.txt", "w");
Fwrite ($FP, Serialize ($PYMB). "");
Fclose ($FP);
}
?>
Application example, add Pinyin to text

/**
Use examples to add pinyin to the text. For the sake of simplification, it is assumed that all Chinese
*/
function Get_py ($text) {
Global $PYMB;
$i = 0;
$n = strlen ($text);
$ar = Array ();

http://www.bkjia.com/PHPjc/631820.html www.bkjia.com true http://www.bkjia.com/PHPjc/631820.html techarticle ? PHP/** Phonetic Code table generation: Start the Input Method Builder in the Inverse Conversion tab, mount the Phonetic IME for window and save it as a text file (winpy.txt) alternate. The following code will spell ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.