【发布时间】:2012-12-11 17:12:41
【问题描述】:
我有以下 PHP 数组结构:
$set = array();
$set[] = array('firstname'=>'firstname 1',
'lastname'=>'lastname 1',
"bio"=>array('paragraph 1 of the bio, 'paragraph 2 of the bio','paragraph 3 of the bio'),
);
然后我使用以下命令访问数组:
<?php $counter = 0;
while ($counter < 1) : //1 for now
$item = $set[$counter]?>
<h1><?php echo $item['firstname'] ?></h1>
<h1><?php echo $item['lastname'] ?></h1>
<?php endwhile; ?>
我不确定如何循环遍历数组的“bio”部分并回显每个段落。
所以作为最终输出,我应该有两个 h1(名字和姓氏)和三个段落(简历)。
我该怎么做?
【问题讨论】:
-
仅供参考,您在生物初始化中缺少单引号
-
所有优秀的答案。如果我能接受所有这些,我会的。谢谢大家!