Data-related questions!

Source: Internet
Author: User
Data questions !! With this result, 024 is the title by accident. 1, 3, and 5 are the IDArray (& nbsp; [0] & gt; of this title. Have you eaten it today! & Nbsp; [1] & gt; 2 & nbsp; [2] & gt; no more today! & Nbsp; [3] & gt; 3 & nbsp; [4] & gt; Ele. me today! & Nbsp data questions !!
With such a result, 0 2 4 happens to be the title, and 1, 3, and 5 indicate the ID of the title.

Array
(
[0] => have you eaten today!
[1] => 2
[2] => don't eat it today!
[3] => 3
[4] => today is really hungry!
[5] => 8
)

How can this problem be solved?



Don't eat it today! (Id = 3)




------ Solution --------------------
With such a result, 0 2 4 happens to be the title, and 1, 3, and 5 indicate the ID of the title.
------ Solution --------------------
PHP code
$ Ar = array (0 => 'Have you eaten today! ', 2,' don't eat today! ', 3,' it's really hungry today! ', 8,); foreach (array_chunk ($ ar, 2) as $ v) $ list [] = array ('id' => $ v [1], 'name' => $ v [0]); print_r ($ list );
------ Solution --------------------
PHP code
$ Array = array ('heading 1', 'id1', 'heading 2', 'id2', 'heading 3', 'id3 '); foreach ($ array as $ key => $ value) {if (isset ($ array [$ key + 1]) $ id = $ array [$ key + 1]; echo ''. $ value. '(id = '. $ id. ')
';}
------ Solution --------------------
PHP code
$ Array = array (); $ arrList = array (); for ($ I = 0; $ I
      ------ Solution --------------------
PHP code
$ Array = array ('id1', 'heading 1', 'id2', 'heading 2', 'id3 ', 'heading 3'); foreach (range (1, count ($ array) * 1/2) as $ val) {echo "". next ($ array ). "\ r \ n"; next ($ array );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.