title: Using PHP's foreach to create array of values from JSON data
body: <p>I'm working with JSON data for the first time and I've got some PHP to grab some JSON data like below (except there are hundreds of <strong>measuregrps</strong> within <strong>body</strong>).</p>
  
  <pre><code>$json = file_get_contents("http://wbsapi.withings.net/measure?action=getmeasures");
  $json_o = json_decode($json);
  </code></pre>
  
  <p>How do I use foreach to, say, create a 1-dimensional array of values for type = 1?</p>
  
  <pre><code>    {
          "status": 0,
          "body": {
              "updatetime": 1249409679,
              "measuregrps": [
                  {
                      "grpid": 2909,
                      "attrib": 0,
                      "date": 1222930968,
                      "category": 1,
                      "measures": [
                          {
                              "value": 79300,
                              "type": 1,
                              "unit": -3
                          },
                          {
                              "value": 652,
                              "type": 5,
                              "unit": -1
                          },
                          {
                              "value": 178,
                              "type": 6,
                              "unit": -1
                          },
                          {
                              "value": 14125,
                              "type": 8,
                              "unit": -3
                          }
                      ]
                  },
                  {
                      "grpid": 2908,
                      "attrib": 0,
                      "date": 1222930968,
                      "category": 1,
                      "measures": [
                          {
                              "value": 78010,
                              "type": 1,
                              "unit": -3
                          }
                      ]
                  },
                  {
                      "grpid": 2907,
                      "attrib": 0,
                      "date": 1222930968,
                      "category": 1,
                      "measures": [
                          {
                              "value": 77300,
                              "type": 1,
                              "unit": -3
                          },
                          {
                              "value": 678,
                              "type": 5,
                              "unit": -1
                          }
  
                      ]
                  },
  
  
              ]
          }
      }
  </code></pre>