What I am trying to do, is read a file containing data such as:
code:
 
Admins
{
 "[ツツ]ア Furry Indigo"
       {
        "auth"      "steam"
        "identity"      "STEAM_0:0:1"
        "group"     "levelmax"
        "immunity"      "998"
    }
 
 "Cherry"
       {
        "auth"      "steam"
        "identity"      "STEAM_0:1:1"
        "group"     "levelmax"
        "immunity"      "997"
    }
  etc
}
How would I go about, reading each entry, and displaying the name, in this case "[ツツ]ア Furry Indigo" or "Cherry", the STEAMID, in this case "STEAM_0:0:1" or "STEAM_0:1:1", the Group, in this case "levelmax", and the immunity level, in this case "998" or "997", and then displaying these in a table?
So far, with the help of others, I've managed to come up with:
code:
$file = 'admins.cfg';
 
$mode = 0; $section = $user = $key = "";
$array = array();
 
for ($i = 0; $i < strlen($file); $i++) {
    $c = $file[$i];
    switch ($mode) {
        case 0: // the section name
            if ($c == "{") {
                $section = trim($section);
                $array[$section] = array();
                $mode = 1; // look for a username
            } else {
                $section .= $c;
            }
            break;
        case 1: // user name (before the first ")
            if ($c == "}") {
                $mode = 0; // section is empty
            } else if ($c == '"') {
                $mode = 2; // get the username
            }
            break;
        case 2: // user name (inside the quotes)
            if ($c == '"') {
                $array[$section][$user] = array();
                $mode = 3;
            } else {
                $user .= $c;
            }
            break;
        case 3: // waiting for the {
            if ($c == "{") $mode = 4;
            break;
        case 4: // key (before the first ")
            if ($c == '"') $mode = 5;
            break;
        case 5: // key
            if ($c == '"') {
                $array[$section][$user][$key] = "";
                $mode = 6;
            } else {
                $key .= $c;
            }
            break;
        case 6: // value (before the first ")
            if ($c == '"') $mode = 7;
            break;
        case 7: // value
            if ($c == '"') {
                $key = "";
                $mode = 8;
            } else {
                $array[$section][$user][$key] .= $c;
            }
            break;
        case 8: // waiting for a " (key) or a }
            if ($c == '"') {
                $mode = 5;
            } else if ($c == "}") {
                $user = "";
                $mode = 9;
            }
            break;
        case 9: // waiting for a " (username) or a }
            if ($c == '"') {
                $mode = 2;
            } else if ($c == "}") {
                $section = "";
                $mode = 0;
            }
            break;
    }
}
var_dump($array);
 
Which produces: 
code:
array(1) {
  ["Admins"]=>
  array(2) {
    ["[ツツ]ア Furry Indigo"]=>
    array(4) {
      ["auth"]=>
      string(5) "steam"
      ["identity"]=>
      string(11) "STEAM_0:0:1"
      ["group"]=>
      string(8) "levelmax"
      ["immunity"]=>
      string(3) "998"
    }
    ["Cherry"]=>
    array(4) {
      ["auth"]=>
      string(5) "steam"
      ["identity"]=>
      string(11) "STEAM_0:1:1"
      ["group"]=>
      string(8) "levelmax"
      ["immunity"]=>
      string(3) "997"
    }
  }
}
But then I have no idea how to extract the name, steamid, group and immunity from this array, display in a table and sort by immunity level?