The array is divided into two sections
A one-dimensional array, note that the key name is irregular and non-numeric:
$arr =array (' WC ' =>12, ' WSSC ' =>123, ' WAC ' =>142 ', ' =>124 ', ' WAC ' =>012, ' wsbsc ' =>012c3, ' WAC ' = 014d2 ', W3ec ' =>0124);
It is now divided into two parts, namely:
$arr 1=array (' WC ' =>12, ' WSSC ' =>123, ' WAC ' =>142 ', ' =>124 ');
And
$arr 2=array (' WAC ' =>012, ' wsbsc ' =>012c3, ' WAC ' =>014d2 ', W3ec ' =>0124 ');
To find this algorithm
------Solution--------------------
You didn't specify any division rules--
Array_chunk ()
Or
Array_slice ()
------Solution--------------------
The condition of the original split is obviously, to determine whether the first character is 0.
Unfortunately, your problem is wrong, because the association key WAC is duplicated. So the array $arr only 7 items
An array of 7 items split into a total of 8 items, because the condition is not sufficient, so no solution!
You're not challenging our IQ, are you?
------Solution--------------------
Regardless of your array there are no errors, but this method should be feasible (elements of an even number, or odd number, the number of a few):
Asort ($arr);
Then intercept the front to OK. For interception, you can use a function, or you can assign a value to another array
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.