Query regarding array_index_exists()

Discussion in 'CommandHelper' started by combat_wombat, Sep 5, 2018.

  1. combat_wombat

    combat_wombat New Member

    I was wondering if anyone can have a look at this for me.

    I'm attempting to check for keys in a multidimensional array in the way that you might do the following in PHP:
    PHP:
    isset($array['one']['two']['three'])
    I had a check of the array_index_exists() documentation and it states
    This, and the fifth example leads me to expect that this will work in the same way that the PHP code would.
    However, in practice it wasn't working. For example:
    PHP:
    @array = array('this':array('that':'example'));
    array_index_exists( @array,'this'); // Resolves to true
    array_index_exists( @array,'that'); // Resolves to false
    array_index_exists( @array,'this','that'); // Resolves to true
    array_index_exists( @array,'this','notakey'); // Also resolves to true....
    Am I misunderstanding, or is this in fact not working as intented? Currently using build 3379 on MC 1.12.2
  2. PseudoKnight

    PseudoKnight Well-Known Member Developer

    It looks like that was added to the documentation accidentally before the feature was implemented. It does not currently recursively check.
  3. combat_wombat

    combat_wombat New Member

    Brilliant, thank you for clarifying.