php mysql如何 循环输出以下数组:
$KeyArray=Array( 0=>array("Key"=>"中国","Href"=>"<ah...
$KeyArray=Array( 0=>array("Key"=>"中国","Href"=>"<a href='中国'>中国</a>","ReplaceNumber"=>2),//只替换一个‘中国’ 1=>array("Key"=>"人","Href"=>"<a href='人'>人</a>","ReplaceNumber"=>1), 2=>array("Key"=>"我","Href"=>"<a href='我'>我</a>","ReplaceNumber"=>1), 3=>array("Key"=>"呵呵","Href"=>"<a href='呵呵'>呵呵</a>","ReplaceNumber"=>0)//全部替换);
展开
2个回答
推荐于2016-05-06 · 知道合伙人软件行家
关注
展开全部
以下循环输出数组的示例代码:
<?php
$KeyArray = array(
0 => array(
"Key" => "中国",
"Href" => "<a href='中国'>中国</a>",
"ReplaceNumber" => 2),
1 => array(
"Key" => "人",
"Href" => "<a href='人'>人</a>",
"ReplaceNumber" => 1),
2 => array(
"Key" => "我",
"Href" => "<a href='我'>我</a>",
"ReplaceNumber" => 1),
3 => array(
"Key" => "呵呵",
"Href" => "<a href='呵呵'>呵呵</a>",
"ReplaceNumber" => 0));
echo '<table border="1">';
for($i=0;$i<count($KeyArray);$i++)
{
echo '<tr>';
foreach($KeyArray[$i] as $key=>$value)
{
echo "<td> $value </td>";
}
echo '</tr>';
}
echo '</table>';
?>
<?php
$KeyArray = array(
0 => array(
"Key" => "中国",
"Href" => "<a href='中国'>中国</a>",
"ReplaceNumber" => 2),
1 => array(
"Key" => "人",
"Href" => "<a href='人'>人</a>",
"ReplaceNumber" => 1),
2 => array(
"Key" => "我",
"Href" => "<a href='我'>我</a>",
"ReplaceNumber" => 1),
3 => array(
"Key" => "呵呵",
"Href" => "<a href='呵呵'>呵呵</a>",
"ReplaceNumber" => 0));
echo '<table border="1">';
for($i=0;$i<count($KeyArray);$i++)
{
echo '<tr>';
foreach($KeyArray[$i] as $key=>$value)
{
echo "<td> $value </td>";
}
echo '</tr>';
}
echo '</table>';
?>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询