3D array. count the number of elements.

Source: Internet
Author: User
3D array: count the number of a certain element. how can I count two elements in the first record of rule_1?

Article 2 and Article 3 may be different. please find them separately. thank you.


Reply to discussion (solution)

Returns the result of serialize (not)


Array (size = 2)
0 =>
Array (size = 16)
'Id' => string '123' (length = 3)
'Uid' => string '1' (length = 1)
'Shopid' => string '20140901' (length = 3)
'Num' => string '2' (length = 1)
'Color' => string '1' (length = 1)
'Freight '=> string '0' (length = 1)
'Mony' => string '2' (length = 1)
0 =>
Array (size = 6)
'Rule_1' =>
Array (size = 3)
...
'Piece '=> string '2' (length = 1)
'Goods _ id' => string '20140901' (length = 3)
'Givenum' => string '2' (length = 1)
'Givename' => string '123' (length = 4)
'Givegoodimg '=> string'' (length = 0)
1 =>
Array (size = 6)
'Rule_1' =>
Array (size = 3)
...
'Piece '=> string '3' (length = 1)
'Goods _ id' => string '20140901' (length = 3)
'Givenum' => string '1' (length = 1)
'Givename' => string 'test09' (length = 6)
'Givegoodimg '=> string 'http: // vshop.com/Uploads/Picture/2015-09-20/55fe739a50002.jpg' (length = 61)
'Spec _ date' => string '11 + 22' (length = 5)
'Goods _ img '=> string 'http: // vshop.com/Uploads/Picture/2015-10-09/561713942c03c.jpg' (length = 61)
'Goods _ name' => string 'test499' (length = 7)
'Price' => string '1. 00' (length = 4)
'Goods _ code' => string 'sc23261406 '(length = 10)
'Volume '=> string '2' (length = 1)
'Unit '=> string '1' (length = 1)
1 =>
Array (size = 15)
'Id' => string '123' (length = 3)
'Uid' => string '1' (length = 1)
'Shopid' => string '20140901' (length = 3)
'Num' => string '5' (length = 1)
'Color' => string '1' (length = 1)
'Freight '=> string '12' (length = 2)
'Mony' => string '50' (length = 2)
0 =>
Array (size = 6)
'Rule_1' =>
Array (size = 3)
...
'Piece '=> string '2' (length = 1)
'Goods _ id' => string '20140901' (length = 3)
'Givenum' => string '3' (length = 1)
'Givename' => string 'l'oreal' hand cream '(length = 15)
'Givegoodimg '=> string'' (length = 0)
'Spec _ date' => string '1 + 3' (length = 3)
'Goods _ img '=> string 'http: // vshop.com/Uploads/Picture/2015-08-31/55e3fa7e0e5f2.jpg' (length = 61)
'Goods _ name' => string 'test02' (length = 6)
'Price' => string '10. 00' (length = 5)
'Goods _ code' => string 'sc60023958 '(length = 10)
'Volume '=> string '3' (length = 1)
'Unit '=> string '1' (length = 1)

Where
Article 1



Array (size = 3)
1 => string '2' (length = 1)
2 => string '20140901' (length = 3)
3 => string '2' (length = 1)

Array (size = 3)
1 => string '3' (length = 1)
2 => string '20140901' (length = 3)
3 => string '1' (length = 1)

The second rule_1 is


Array (size = 3)
1 => string '2' (length = 1)
2 => string '20140901' (length = 3)
3 => string '3' (length = 1)

Since you like to defend against all attacks
Observe that rule_1 belongs to the three-dimensional association key, and you just need to traverse it through a double loop.



Tutorial
Get a double loop and traverse it.
How can this problem be solved? Indeed, the data is not very good friends.

It is troublesome to loop out. this is used in order. the promotion rules for each item are different. one item has two

How do I write code without data?
Is it hard for me to create some data for you?

Thank you.

$ Nn = 0; foreach ($ shop_list as $ key => & $ val) {for ($ I = 0; $ I
  
  



Great gods like to simulate data.

Thanks. it's out.

I do not like to simulate data.
However, since we are teaching you how to do this, we must provide code that can pass the test.
What do you mean

Thank you ~~~

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.