デモページを作成しました。 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"をテキストとしてエコーする方法はありますか?
あなたの質問に関連するコードはありますか? –
これは簡単ではありません。 – drudge
@Oli Charlesworth、はい。 – Taffarel