Php array problems
I dumped an array and it is shown as follows:
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" }}
What should I do when I want to output this output?
Question: 11111111111 option: A content: aaaaaaa1111111 option: B content: bbbbbbbbbbbb option: C content: cccccccc problem: 222222222 option: D content: ddddddddddd option: EF content: efe2efef2fef option: F content: fff32fffffff problem: 333333333 option: GG content: ggg323ggggggg option: H content: hhh5h5h5h5 option: J content: j8j8j8j8
Reply to discussion (solution)
Just now, let's see:
Foreach ($ a as $ v) {if ($ qid! = $ V ['Ops _ qid']) {echo 'problem:'. $ v ['Que _ content']."
"; $ Qid = $ v ['Ops _ qid'];} else {echo 'option :'. $ v ['Ops _ contentoid']. 'content '. $ v ['Ops _ content']."
";}}
It seems to be slightly changed:
The code is as follows:
Foreach ($ a as $ v) {if ($ qid! = $ V ['Ops _ qid']) {echo 'problem:'. $ v ['Que _ content']."
"; Echo 'option:'. $ v ['Ops _ contentoid']. 'content'. $ v ['Ops _ content']."
"; $ Qid = $ v ['Ops _ qid'];} else {echo 'option :'. $ v ['Ops _ contentoid']. 'content '. $ v ['Ops _ content']."
";}}
If ($ qid! = $ V ['Ops _ qid'])
$ Qid refers to what?
$ Qid is a temporary variable used to store the ops_qid of the previous round. In this way, you can check whether the problem is new.
To nowphp
Why do I need to change it to #2? Can I just delete the #1 else?
$ Qid is a temporary variable used to store the ops_qid of the previous round. In this way, you can check whether the problem is new.
To nowphp
Why do I need to change it to #2? Can I just delete the #1 else? Yes, yes, the moderator is careful. I am careless.