Split the array of the php algorithm without the array_chunk () _ PHP Tutorial

Source: Internet
Author: User
Use the php algorithm to separate arrays without array_chunk (). Use the php algorithm to split the array, instead of using array_chunk () to separate the array, rather than using the php algorithm (). The algorithm is shown below. $ Value) {whether this value exists if (! Isset ($ newarray [$ I] an array separated by the php algorithm, without the use of array_chunk ()

Use the php write algorithm to split the array without using array_chunk (). The algorithm is as follows.

 $ Value) {// whether this value exists if (! Isset ($ newarray [$ I]) {$ newarray [$ I] = array ();} if (count ($ newarray [$ I]) <$ size) {// first-identified problem if ($ preserve_keys = false) {$ newarray [$ I] [] = $ value ;} else {$ newarray [$ I] [$ key] = $ value ;}} else {$ I ++; if ($ preserve_keys = false) {$ newarray [$ I] [] = $ value;} else {$ newarray [$ I] [$ key] = $ value ;}} return $ newarray ;} $ array = array (1, 2, 3, 4, 5, 6, 7); print_r (array_chunk_list ($ array, 2, true ));


The http://www.bkjia.com/PHPjc/892831.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/892831.htmlTechArticlephp algorithm of the split array, do not use array_chunk () write algorithm to split the array, do not use array_chunk (); the algorithm is as follows. $ Value) {// whether this value exists if (! Isset ($ newarray [$ I]...

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.