我dump了一个数组,显示如下:
array(9) {
[0] => array(6) {
["que_content"] => string(11) "11111111111"
["que_id"] => string(1) "1"
["ops_qid"] => string(1) "1"
["ops_contentoid"] => string(1) "A"
["ops_content"] => string(14) "aaaaaaa1111111"
["ops_count"] => string(1) "3"
}
[1] => array(6) {
["que_content"] => string(11) "11111111111"
["que_id"] => string(1) "1"
["ops_qid"] => string(1) "1"
["ops_contentoid"] => string(1) "B"
["ops_content"] => string(10) "bbbbbbbbbb"
["ops_count"] => string(1) "1"
}
[2] => array(6) {
["que_content"] => string(11) "11111111111"
["que_id"] => string(1) "1"
["ops_qid"] => string(1) "1"
["ops_contentoid"] => string(1) "C"
["ops_content"] => string(8) "cccccccc"
["ops_count"] => string(1) "1"
}
[3] => array(6) {
["que_content"] => string(9) "222222222"
["que_id"] => string(1) "2"
["ops_qid"] => string(1) "2"
["ops_contentoid"] => string(1) "D"
["ops_content"] => string(9) "ddddddddd"
["ops_count"] => string(1) "3"
}
[4] => array(6) {
["que_content"] => string(9) "222222222"
["que_id"] => string(1) "2"
["ops_qid"] => string(1) "2"
["ops_contentoid"] => string(2) "EF"
["ops_content"] => string(12) "efe2efef2fef"
["ops_count"] => string(1) "1"
}
[5] => array(6) {
["que_content"] => string(9) "222222222"
["que_id"] => string(1) "2"
["ops_qid"] => string(1) "2"
["ops_contentoid"] => string(1) "F"
["ops_content"] => string(14) "fff32fffffffff"
["ops_count"] => string(1) "1"
}
[6] => array(6) {
["que_content"] => string(9) "333333333"
["que_id"] => string(1) "3"
["ops_qid"] => string(1) "3"
["ops_contentoid"] => string(2) "GG"
["ops_content"] => string(13) "ggg323ggggggg"
["ops_count"] => string(1) "1"
}
[7] => array(6) {
["que_content"] => string(9) "333333333"
["que_id"] => string(1) "3"
["ops_qid"] => string(1) "3"
["ops_contentoid"] => string(1) "H"
["ops_content"] => string(10) "hhh5h5h5h5"
["ops_count"] => string(1) "2"
}
[8] => array(6) {
["que_content"] => string(9) "333333333"
["que_id"] => string(1) "3"
["ops_qid"] => string(1) "3"
["ops_contentoid"] => string(1) "J"
["ops_content"] => string(8) "j8j8j8j8"
["ops_count"] => string(1) "2"
}
}我想输出的时候这样子输出,应该要怎样做?
问题:11111111111
选项:A 内容:aaaaaaa1111111
选项:B 内容:bbbbbbbbbb
选项:C 内容:cccccccc
问题:222222222
选项:D 内容:ddddddddd
选项:EF 内容:efe2efef2fef
选项:F 内容:fff32fffffffff
问题:333333333
选项:GG 内容:ggg323ggggggg
选项:H 内容:hhh5h5h5h5
选项:J 内容:j8j8j8j8php数组输出
array(9) {
[0] => array(6) {
["que_content"] => string(11) "11111111111"
["que_id"] => string(1) "1"
["ops_qid"] => string(1) "1"
["ops_contentoid"] => string(1) "A"
["ops_content"] => string(14) "aaaaaaa1111111"
["ops_count"] => string(1) "3"
}
[1] => array(6) {
["que_content"] => string(11) "11111111111"
["que_id"] => string(1) "1"
["ops_qid"] => string(1) "1"
["ops_contentoid"] => string(1) "B"
["ops_content"] => string(10) "bbbbbbbbbb"
["ops_count"] => string(1) "1"
}
[2] => array(6) {
["que_content"] => string(11) "11111111111"
["que_id"] => string(1) "1"
["ops_qid"] => string(1) "1"
["ops_contentoid"] => string(1) "C"
["ops_content"] => string(8) "cccccccc"
["ops_count"] => string(1) "1"
}
[3] => array(6) {
["que_content"] => string(9) "222222222"
["que_id"] => string(1) "2"
["ops_qid"] => string(1) "2"
["ops_contentoid"] => string(1) "D"
["ops_content"] => string(9) "ddddddddd"
["ops_count"] => string(1) "3"
}
[4] => array(6) {
["que_content"] => string(9) "222222222"
["que_id"] => string(1) "2"
["ops_qid"] => string(1) "2"
["ops_contentoid"] => string(2) "EF"
["ops_content"] => string(12) "efe2efef2fef"
["ops_count"] => string(1) "1"
}
[5] => array(6) {
["que_content"] => string(9) "222222222"
["que_id"] => string(1) "2"
["ops_qid"] => string(1) "2"
["ops_contentoid"] => string(1) "F"
["ops_content"] => string(14) "fff32fffffffff"
["ops_count"] => string(1) "1"
}
[6] => array(6) {
["que_content"] => string(9) "333333333"
["que_id"] => string(1) "3"
["ops_qid"] => string(1) "3"
["ops_contentoid"] => string(2) "GG"
["ops_content"] => string(13) "ggg323ggggggg"
["ops_count"] => string(1) "1"
}
[7] => array(6) {
["que_content"] => string(9) "333333333"
["que_id"] => string(1) "3"
["ops_qid"] => string(1) "3"
["ops_contentoid"] => string(1) "H"
["ops_content"] => string(10) "hhh5h5h5h5"
["ops_count"] => string(1) "2"
}
[8] => array(6) {
["que_content"] => string(9) "333333333"
["que_id"] => string(1) "3"
["ops_qid"] => string(1) "3"
["ops_contentoid"] => string(1) "J"
["ops_content"] => string(8) "j8j8j8j8"
["ops_count"] => string(1) "2"
}
}我想输出的时候这样子输出,应该要怎样做?
问题:11111111111
选项:A 内容:aaaaaaa1111111
选项:B 内容:bbbbbbbbbb
选项:C 内容:cccccccc
问题:222222222
选项:D 内容:ddddddddd
选项:EF 内容:efe2efef2fef
选项:F 内容:fff32fffffffff
问题:333333333
选项:GG 内容:ggg323ggggggg
选项:H 内容:hhh5h5h5h5
选项:J 内容:j8j8j8j8php数组输出
解决方案 »
- 想要买本关于PHP的书
- 求发送邮件不被封的解决方案。
- [教程]PHP建立SOAP服务器教程,PHP请求访问SOAP服务器教程
- 为什么都喜欢用文本编辑器,如Notepad++, EditPlus, Sublime text, EmEditor, 都说DW不好呢?
- 如何防止IE打开EXCEL,在下载EXCEl文档的时候?
- php中substr一问
- 各位,进来看看吧!
- phpmyadmin为何安装不成功?
- 问题请教-网页中可不可以直接显示幻灯片格式的文件(.ppt)象图片那样显示????
- 我有一個調查的頁面,有 checkbox 也有 input 我想填好后以 html 頁面的形式用 email 發送回我信箱中,這個要怎麼實現!!!!!
- PHP自动登录新浪微博 出现问题 CURL ERROR: malformed
- php 用绝对路径跳转问题
if($qid!=$v['ops_qid']){
echo '问题:'.$v['que_content']."<br>";
$qid=$v['ops_qid'];
}else{
echo '选项:'.$v['ops_contentoid'].' 内容'.$v['ops_content']."<br>";
}
}
代码如下:
foreach($a as $v){
if($qid!=$v['ops_qid']){
echo '问题:'.$v['que_content']."<br>";
echo '选项:'.$v['ops_contentoid'].' 内容'.$v['ops_content']."<br>";
$qid=$v['ops_qid'];
}else{
echo '选项:'.$v['ops_contentoid'].' 内容'.$v['ops_content']."<br>";
}
}
为什么要改成 #2 的样子,将 #1 的 else 删掉不就可以了吗?