基礎から解る!PHP入門講座 プログラム入門に最適な言語、PHPを学ぼう

基礎から解る!PHP入門講座

プログラム入門に最適な言語、PHPを学ぼう      

    半角と全角 19−1

    <?php
    error_reporting(1);
    function ALPHAHALF ($data){
      $trans = array(
      "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5",
      "6" => "6", "7" => "7", "8" => "8", "9" => "9", "0" => "0",
      "A" => "A", "B" => "B", "C" => "C", "D" => "D", "E" => "E",
      "F" => "F", "G" => "G", "H" => "H", "I" => "I", "J" => "J",
      "K" => "K", "L" => "L", "M" => "M", "N" => "N", "O" => "O",
      "P" => "P", "Q" => "Q", "R" => "R", "S" => "S", "T" => "T",
      "U" => "U", "V" => "V", "W" => "W", "X" => "X", "Y" => "Y", "Z" => "Z",
      "a" => "a", "b" => "b", "c" => "c", "d" => "d", "e" => "e",
      "f" => "f", "g" => "g", "h" => "h", "i" => "i", "j" => "j",
      "k" => "k", "l" => "l", "m" => "m", "n" => "n", "o" => "o",
      "p" => "p", "q" => "q", "r" => "r", "s" => "s", "t" => "t",
      "u" => "u", "v" => "v", "w" => "w", "x" => "x", "y" => "y", "z" => "z",
      "@" => "@", "(" => "(", ")" => ")", "−" => "-", "#" => "#",
      "!" => "!", "?" => "?", "*" => "*", ";" => ";", ":" => ":",
      "/" => "/", "_" => "_", " " => " ", );
      $new_data = strtr($data, $trans);
      return $new_data;
    }
    /*----------------------------------------------------------------*/
    function KANAFULL ($data){
      $trans = array(
      "ア" => "ア", "イ" => "イ", "ウ" => "ウ", "エ" => "エ", "オ" => "オ",
      "カ" => "カ", "キ" => "キ", "ク" => "ク", "ケ" => "ケ", "コ" => "コ",
      "サ" => "サ", "シ" => "シ", "ス" => "ス", "セ" => "セ", "ソ" => "ソ",
      "タ" => "タ", "チ" => "チ", "ツ" => "ツ", "テ" => "テ", "ト" => "ト",
      "ナ" => "ナ", "ニ" => "ニ", "ヌ" => "ヌ", "ネ" => "ネ", "ノ" => "ノ",
      "ハ" => "ハ", "ヒ" => "ヒ", "フ" => "フ", "ヘ" => "ヘ", "ホ" => "ホ",
      "マ" => "マ", "ミ" => "ミ", "ム" => "ム", "メ" => "メ", "モ" => "モ",
      "ヤ" => "ヤ", "ユ" => "ユ", "ヨ" => "ヨ",
      "ラ" => "ラ", "リ" => "リ", "ル" => "ル", "レ" => "レ", "ロ" => "ロ", "ン" => "ン",
      "ガ" => "ガ","ギ" => "ギ","グ" => "グ","ゲ" => "ゲ","ゴ" => "ゴ",
      "ザ" => "ザ","ジ" => "ジ","ズ" => "ズ","ゼ" => "ゼ","ゾ" => "ゾ",
      "ダ" => "ダ","ヂ" => "ヂ","ヅ" => "ヅ","デ" => "デ","ド" => "ド",
      "バ" => "バ","ビ" => "ビ","ブ" => "ブ","ベ" => "ベ","ボ" => "ボ",
      "パ" => "パ","ピ" => "ピ","プ" => "プ","ペ" => "ペ","ポ" => "ポ","ヲ" => "ヲ",
      "ァ" => "ァ","ィ" => "ィ","ゥ" => "ゥ","ェ" => "ェ","ォ" => "ォ",
      "ヴ" => "ヴ","ヵ" => "ヵ","ヶ" => "ヶ",
      "ャ" => "ャ","ュ" => "ュ","ョ" => "ョ","ッ" => "ッ","ー" => "ー",
      "、" => "、","。" => "。",  "「" => "「","」" => "」", );
      $new_data = strtr($data, $trans);
      return $new_data;
    }
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html lang="ja">
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=EUC-JP">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <link rel="stylesheet" href="../style.css">
    <style TYPE="text/css">
    <!--
    .area {
    width:700px;
    text-align:left;
    margin:10px;
    padding:15px;
    border-style:ridge;
    border-color:#ffff22;
    border-width:1px;
    font-size:13px;
    color:#000000;
    line-height:19px
    }
    -->
    </style></head>
    <body><div class="file2">
    <?php
    $data = $_POST['data'];
    $data = ALPHAHALF($data);
    $data = KANAFULL($data);
    echo "<div class='area' style='font-weight:bold;font-size:20px;'>半角カタカナを全角に・全角英数を半角に!</div>";
    echo "<div class='area'><form action='19_01_kana.php' method='post'>";
    echo "<textarea name='data' cols='90' rows='6'>
    プログレッシブ・ロックという言葉は、1970年に発売されたピンク・フロイドのアルバム『原子心母/Atom Heart Mother』が発売された際、従来のロックとは異なるピンク・フロイドの音楽を形容するために考案されたものといわれている。
    しかし、”PROGRESSIVE ROCK”は英語でも普通に使われている言葉であり、海外で生まれたと考えるのが自然であろう。</textarea><br><br>";
    echo "<input type='submit' value='Change'> 全角カタカナ・半角英数に変換します。↑書き換えることもできます。</form></div>";
    $data = str_replace("¥n", '<br>', $data);
    $data = str_replace("¥¥", '', $data);
    echo "<div class='area'>$data</div>";
    ?>

    </div></body></html>
    2019/3
    SUN MON TUE WED THU FRI SAT
              1 2
    3 4 5 6 7 8 9
    10 11 12 13 14 15 16
    17 18 19 20 21 22 23
    24 25 26 27 28 29 30
    31       


     フォクすけ©2006 Mozilla Japan



    制作:基礎から解るPHP入門講座 代表:FREEZE

    Copyright © 2005/2/28 flzPHP.All Rights Riserved