Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Counting and exploding an array

Comments in 'Plugin Development' started by PEMapModder, Jan 14, 2014.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    How do I count how many items and sub-items are in an array? I am thinking of the while(is_array($a)) loop but I failed to write the code out. (My brain exploded instead)

    Like,
    array(
    array(
    array("a","b"),
    array("c","d"),
    array(array("e","f"),array("g","h")),
    ),
    array("i"),
    array("j")
    )

    In the above, I want to write a function that counts there are 10 objects/literals/non-arrays.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I want to make it split a large config file into pieces of like, 50 non-arrays, to optimize efficiency, and add an "index.yml" file to see which file to read to get the wanted data.

    Or easier just log them (READ-ONLY)
  3. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
  4. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    You can count a a array with count
  5. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    He wants to count a multidimensional array recursively, without counting keys which point to arrays.
  6. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Ohh
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder

Share This Page

Advertisement