2011-01-27 9 views
0

デモページを作成しました。 Demophpの配列を使って実際のテキストを取得する

PHPのソース:

<?php 
$hoppa = array 
(
    "0" => array 
     ("0","0","0","0","0","0","0","0","0","0"), 
    "1" => array 
     ("0","0","0","0","0","0","0","0","0","0"),  
    "2" => array 
     ("1","0","0","1","0","0","0","0","0","0"), 
    "3" => array 
     ("1","0","0","1","0","1","1","1","1","0"), 
    "4" => array 
     ("1","1","1","1","0","0","0","0","1","0"), 
    "5" => array 
     ("1","0","0","1","0","1","1","1","1","0"), 
    "6" => array 
     ("1","0","0","1","0","1","0","0","1","0"), 
    "7" => array 
     ("1","0","0","1","0","1","1","1","1","0"), 
    "8" => array 
     ("0","0","0","0","0","0","0","0","0","0"), 
    "9" => array 
     ("0","0","0","0","0","0","0","0","0","0")         

); 
function showmee($hoppa) { 
echo '<table width="500px" cellpadding="4" cellspacing="4" border="5" bordercolor="#ededed">'; 
echo '<tr> 
<td align="center" style="border:1px solid blue">-</td> 
<td align="center" style="border:1px solid blue">x1</td> 
<td align="center" style="border:1px solid blue">x2</td> 
<td align="center" style="border:1px solid blue">x3</td> 
<td align="center" style="border:1px solid blue">x4</td> 
<td align="center" style="border:1px solid blue">x5</td> 
<td align="center" style="border:1px solid blue">x6</td> 
<td align="center" style="border:1px solid blue">x7</td> 
<td align="center" style="border:1px solid blue">x8</td> 
<td align="center" style="border:1px solid blue">x9</td> 
<td align="center" style="border:1px solid blue">x10</td> 
</tr>'; 
$count = 1; 
foreach($hoppa as $h=>$g) { 
    echo '<tr>'; 
    echo '<td align="center" style="border:1px solid blue">y'.$count++.'</td>'; 
    foreach($hoppa[$h] as $p) { 
     if($p==1){  
     echo '<td align="center" style="border:1px solid blue; background-color:orange; color:#FFFFFF">1</td>'; 
     } 
     else{ 
     echo '<td align="center" style="border:1px solid blue">0</td>'; 
     } 
     } 
    echo '</tr>'; 


    } 

    echo '</table>'; 
    } 
?> 
<title>Test page for stackoverflow.com</title> 
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:15px;"> 
<tr> 
<td style="border-bottom:1px solid #66CC00;padding-bottom:7px;"><b>Hi, this is Taffarel from stackoverflow.com.</b><br /> 
My problem: I'd like to read(or get) actual text by using PHP. 
</td> 
</tr> 
</table> 
<table width="100%" cellpadding="0" cellspacing="0" border="0"> 
<tr> 
<td width="1"> 
<!-- Codes are begining from here --> 
<?php showmee($hoppa); ?> 
<!-- Codes are ending here --> 
</td> 
<td align="left" style="padding-left:20px;" valign="top"> 
<table> 
<tr> 
<td> 
Php array output (0 = white , 1 = red): 
</td> 
</tr> 
<tr> 
<td> 
<textarea rows="20" name="S1" cols="61"> 
<?php print_r($hoppa); ?> 
</textarea> 
</td> 
</tr> 
</table> 
</td> 
</tr> 
</table> 
<table cellpadding="0" cellspacing="0" border="0" width="500px" style="margin-top:15px;border-top:1px solid #0066FF"><tr><td style="padding-top:5px;">How can i echo "Ha" as text by using PHP?</td></tr></table> 

PHPの配列の出力(0 =白、1 =赤):私はPHPを使って、実際のテキストを読んで(または取得)したいのですが

Array 
(
    [0] => Array 
     (
      [0] => 0 
      [1] => 0 
      [2] => 0 
      [3] => 0 
      [4] => 0 
      [5] => 0 
      [6] => 0 
      [7] => 0 
      [8] => 0 
      [9] => 0 
     ) 

    [1] => Array 
     (
      [0] => 0 
      [1] => 0 
      [2] => 0 
      [3] => 0 
      [4] => 0 
      [5] => 0 
      [6] => 0 
      [7] => 0 
      [8] => 0 
      [9] => 0 
     ) 

    [2] => Array 
     (
      [0] => 1 
      [1] => 0 
      [2] => 0 
      [3] => 1 
      [4] => 0 
      [5] => 0 
      [6] => 0 
      [7] => 0 
      [8] => 0 
      [9] => 0 
     ) 

    [3] => Array 
     (
      [0] => 1 
      [1] => 0 
      [2] => 0 
      [3] => 1 
      [4] => 0 
      [5] => 1 
      [6] => 1 
      [7] => 1 
      [8] => 1 
      [9] => 0 
     ) 

    [4] => Array 
     (
      [0] => 1 
      [1] => 1 
      [2] => 1 
      [3] => 1 
      [4] => 0 
      [5] => 0 
      [6] => 0 
      [7] => 0 
      [8] => 1 
      [9] => 0 
     ) 

    [5] => Array 
     (
      [0] => 1 
      [1] => 0 
      [2] => 0 
      [3] => 1 
      [4] => 0 
      [5] => 1 
      [6] => 1 
      [7] => 1 
      [8] => 1 
      [9] => 0 
     ) 

    [6] => Array 
     (
      [0] => 1 
      [1] => 0 
      [2] => 0 
      [3] => 1 
      [4] => 0 
      [5] => 1 
      [6] => 0 
      [7] => 0 
      [8] => 1 
      [9] => 0 
     ) 

    [7] => Array 
     (
      [0] => 1 
      [1] => 0 
      [2] => 0 
      [3] => 1 
      [4] => 0 
      [5] => 1 
      [6] => 1 
      [7] => 1 
      [8] => 1 
      [9] => 0 
     ) 

    [8] => Array 
     (
      [0] => 0 
      [1] => 0 
      [2] => 0 
      [3] => 0 
      [4] => 0 
      [5] => 0 
      [6] => 0 
      [7] => 0 
      [8] => 0 
      [9] => 0 
     ) 

    [9] => Array 
     (
      [0] => 0 
      [1] => 0 
      [2] => 0 
      [3] => 0 
      [4] => 0 
      [5] => 0 
      [6] => 0 
      [7] => 0 
      [8] => 0 
      [9] => 0 
     ) 

) 

。 PHPを使って "Ha"をテキストとしてエコーする方法はありますか?

+0

あなたの質問に関連するコードはありますか? –

+3

これは簡単ではありません。 – drudge

+0

@Oli Charlesworth、はい。 – Taffarel

答えて

0

印刷する可能性のある文字ごとにマッピングを行う必要があります。次に、配列をループして一致するかどうかを確認する必要があります。オール0の配列が次の文字に移動するシグナルであると仮定します。 これは本当に面倒で時間がかかるようです。

全体的な目標は何ですか?多分、全体にアプローチするより良い方法があります。

+0

新しいcaptchaシステムを作成しています。セキュリティ上の理由から、私はそのテキストを読む必要があります。これは今は不可能だと思われます。とにかく、あなたの助けをありがとう。 – Taffarel

0

光学式文字認識を実行しようとしている場合は、ライブラリの一部を使用する方がよい場合があります(phpOCRなど)。アルゴリズムに興味があれば、それらのライブラリの1つのソースコードを読んでください。短い答えを使って説明できるとは思わないでください。

関連する問題