<?php$year = date('Y');
$month = date('m');
?>
<?
echo json_encode(
array(
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-11",
'url' => "http://yahoo.com/"
),
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-12",
'url' => "http://yahoo.com/"
),
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-13",
'url' => "http://yahoo.com/"
),
)
);
?>我想把array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
用foreach使用,怎么弄?
$month = date('m');
?>
<?
echo json_encode(
array(
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-11",
'url' => "http://yahoo.com/"
),
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-12",
'url' => "http://yahoo.com/"
),
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-13",
'url' => "http://yahoo.com/"
),
)
);
?>我想把array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
用foreach使用,怎么弄?
foreach($row as $key=>$value) {
print "key=$key, value=$value";
}
}$array1是你提到的数据的最外层的那个数组,得到的$row是里面的数组
$erwei=array(array("广州","湖南","江西"),array("北京","上海","深圳"));
for($i=0;$i<=1;$i++){for($j=0;$j<=2;$j++){
echo $erwei[$i][$j];}
echo "<br>";
}//for遍历
$erwei2=array("one"=>array("name"=>"张三","age"=>"21","sex"=>"男"),"two"=>array('name'=>"李四",'age'=>"20",'sex'=>"女"));
foreach ($erwei2 as $key=>$values){
foreach ($values as $key2=>$values2){
echo $values2;
}
echo "<br>";
}//foreach遍历
?>
foreach ($values as $key2=>$values2){
$new[$key2]=$values2;
}
echo "<br>";
}//foreach遍历print_r($new);