I've created a demo page for you. Demo
Php Source:
<?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 array output ( 0 = white , 1 = red):
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
)
)
I'd like to read(or get) actual text by using PHP. How can i echo "Ha" as text by using PHP?
You would have to do some kind of mapping out for each character you might potentially print out. Then you would have to loop through the array and see if you got matches. Assuming an all-0 array was a signal to move on to the next letter. That seems like it would be really messy, and time-consuming.
What is your overall goal? Maybe there is a better way to approach the whole thing.
If you are trying to do Optical Character Recognition then you are better off using some library, phpOCR, for example. if you are interested in algorithm, then just read the source code of one of those libraries. Don't think it can be explained using a short answer.
精彩评论