duanfan8360 2011-07-26 03:13
浏览 73

每次我在PHP中进行正则表达式拆分时,PHP返回的数组中的第一个和最后一个字符串显示为空

I am making a platform to learn Japanese and I have over 2000 hiraganas, katakanas and kanjis and their respective romajis (they are the sound they make when you pronounce them) that I want to insert into a MySQL database. but the problem is that I have them in a string like this (this are just the katakanas, imagine now over 2000 Asian characters more!):

    $string = "a    ア   ka  カ   sa  サ   ta  タ   na  ナ
    i   イ   ki  キ   shi シ   chi チ   ni  ニ
    u   ウ   ku  ク   su  ス   tsu ツ   nu  ヌ
    e   エ   ke  ケ   se  セ   te  テ   ne  ネ
    o   オ   ko  コ   so  ソ   to  ト   no  ノ
    ha  ハ   ma  マ   ya  ヤ   ra  ラ   wa  ワ
    hi  ヒ   mi  ミ           ri  リ   (wi)    ヰ
    fu  フ   mu  ム   yu  ユ   ru  ル   n   ン
    he  ヘ   me  メ           re  レ   (we)    ヱ
    ho  ホ   mo  モ   yo  ヨ   ro  ロ   (w)o    ヲ   ga  ガ   za  ザ   da  ダ   ba  バ   pa  パ
    gi  ギ   ji  ジ   ji  ヂ   bi  ビ   pi  ピ
    gu  グ   zu  ズ   zu  ヅ   bu  ブ   pu  プ
    ge  ゲ   ze  ゼ   de  デ   be  ベ   pe  ペ
    go  ゴ   zo  ゾ   do  ド   bo  ボ   po  ポ

    kya キャ  sha シャ  cha チャ  hya ヒャ  pya ピャ
    kyu キュ  shu シュ  chu チュ  hyu ヒュ  pyu ピュ
    kyo キョ  sho ショ  cho チョ  hyo ヒョ  pyo ピョ

    gya ギャ  ja  ジャ  nya ニャ  bya ビャ  mya ミャ
    gya ギュ  ju  ジュ  nyu ニュ  byu ビュ  my  ミュ
    gyo ギョ  jo  ジョ  nyo ニョ  byo ビョ  myo ミョ
    rya リャ  ryu リュ  ryu リョ  (ja)    ヂャ  (ju)    ヂュ";

So far I could split them between Asian characters and romajis, but with it also split tabulations, and there are blank characters in the first and last part of the array.

  • 写回答

4条回答 默认 最新

  • dongyi2993 2011-07-26 03:22
    关注

    You should consider exploding the string into an array, using the tab as delimiter. Once you have the array you can loop through it separating out the characters. That's how I'd start.

    php.net is going to be a great resource for you, check out the explode() function.

    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波