{
  "id": "06",
  "content": [
    {
      "type": "heading",
      "text": "Arrays & Looping"
    },
    {
      "type": "text",
      "html": "Arrays can be indexed or associative."
    },
    {
      "type": "text",
      "html": "<pre><code>&lt;?php\n $colors = ['blue','green'];\n foreach ($colors as $c) { echo $c; }\n\n $user = ['name' =&gt; 'Xavier', 'role' =&gt; 'admin'];\n foreach ($user as $k =&gt; $v) { echo \"$k: $v\\n\"; }\n</code></pre>"
    },
    {
      "type": "text",
      "html": "Other loops: <code>for</code>, <code>while</code>, <code>do...while</code>."
    }
  ],
  "quiz": {
    "questions": [
      {
        "id": "q1",
        "type": "single",
        "text": "Which loop iterates key/value pairs?",
        "options": [
          {
            "id": "a",
            "text": "foreach ($arr as $k => $v)"
          },
          {
            "id": "b",
            "text": "loop keys"
          },
          {
            "id": "c",
            "text": "for in"
          }
        ],
        "correct": [
          "a"
        ]
      },
      {
        "id": "q2",
        "type": "single",
        "text": "Associative arrays use:",
        "options": [
          {
            "id": "a",
            "text": "Numeric indexes only"
          },
          {
            "id": "b",
            "text": "String keys"
          },
          {
            "id": "c",
            "text": "XML tags"
          }
        ],
        "correct": [
          "b"
        ]
      }
    ]
  }
}