1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Two Arrays inside an Array

Discussion in 'Development' started by ShushImSam, Aug 12, 2019.

  1. ShushImSam

    ShushImSam Spider Jockey

    Messages:
    37
    okay so I know it looks dumb, but basically.. how would I make this(its an example without code on php.net)
    Code:
    Ban:
    - Reason: BL394D
    - Reason: BL4438H
    
    In my YAML
    PHP:
      ["Ban"]=>
      array() {
        [
    0]=>
        array(
    4) {
          [
    "Reason"]=>
          
    string(6"BL394D"
        
    }
        [
    1]=>
        array() {
          [
    "Reason"]=>
          
    string(7"BL4438H"
        
    }
      }
    So once some gets banned , I get the reason and I throw it into his Ban array. I know how to do that. Though I don't know how to set the second one without overwriting
     
  2. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you can append values to the array
    PHP:
    /** @var array $ban_array */
    $ban_array[]["Reason"] = "Hello";
     
  3. ShushImSam

    ShushImSam Spider Jockey

    Messages:
    37
    It still overrides the first one
     
  4. ShushImSam

    ShushImSam Spider Jockey

    Messages:
    37
    I just used an ENUM config for every player, it is easier that way.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.