[英]PHP Array - some further problems with displaying elements in the array
使用Brian的建議:
foreach($qs as $value){
echo "<tr>".$value['qnum']." is the questions number and the question text is ".$value['qtext'].". The page and q values are ".$value['page']." and ".$value['questions']." respectively.</tr>";
}
我從數組中獲得以下輸出,這是不正確的:
8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively
任何進一步的建議。
荷馬
你好,我們又見面了,
先謝謝您的幫助。
這是我基於$rowq
數組:
Array (
[0] => Array (
[questions] => q8
[qnum] => 8
[qtext] => I know how what I do fits into my team's objectives
[page] => 1
)
[1] => Array (
[questions] => q8
[qnum] => 8
[qtext] => I know how what I do fits into my team's objectives
[page] => 1
)
[2] => Array (
[questions] => q8
[qnum] => 8
[qtext] => I know how what I do fits into my team's objectives
[page] => 1
)
[3] => Array (
[questions] => q8
[qnum] => 8
[qtext] => I know how what I do fits into my team's objectives
[page] => 1
)
[4] => Array (
[questions] => q8
[qnum] => 8
[qtext] => I know how what I do fits into my team's objectives
[page] => 1
)
[5] => Array (
[questions] => q8
[qnum] => 8
[qtext] => I know how what I do fits into my team's objectives
[page] => 1
)
[6] => Array (
[questions] => q8
[qnum] => 8
[qtext] => I know how what I do fits into my team's objectives
[page] => 1
)
[7] => Array (
[questions] => q8
[qnum] => 8
[qtext] => I know how what I do fits into my team's objectives
[page] => 1
)
)
我想顯示數組的元素,使用(我認為) foreach
語句遍歷每一行,但我無法使其正常工作,理想情況下,我想回顯類似的內容
echo "<tr>".$rowq[qnum]." is the questions number and the question text is ".$rowq[qtext].". The page and q values are ".$rowq[page]." and ".$rowq[questions]." respectively.";
不管該數組中包含多少行,該文本鏈接都會出現。
任何和所有建議都值得贊賞-我正竭盡全力爭取多維數組:(
荷馬
來自TriLLi的修改
1)您不需要$ key,因為您從不使用它-實際上php將報告警告或通知
2)如果不需要,請避免使用錯誤抑制運算符@
3)您還想要<tr>
標簽,對嗎?
foreach($rowq as $value){
echo "<tr><td>".$value['qnum']." is the questions number
and the question text is ".$value['qtext'].". The page and q values are".
$value['page']." and ".$value['questions']." respectively.</td></tr>";
}
使用以下代碼foreach($rowq as $key => $value)
{
echo @"".$value['qnum']." is the questions number and the question text is ".$value['qtext'].". The page and q values are ".$value['page']." and ".$value['questions']." respectively.";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.