title: How to find specific key in JSON which I decoded into PHP? The key I want to find is repeated on multiple level of nesting
body: <blockquote>
    <p>I want to target "KeyIwanttotarget" which is present on outside as well as nested.</p>
  </blockquote>
  
  <p>The original file is JSON which I decoded into php using json_decode(). I want to target the specific key on all levels(external as well as nested) and store the value into another array e.g. using foreach and array_push.</p>
  
  <pre><code>"sample": [
      {
          "KeyIwanttotarget": "link",
          "abc": "123",
          "xyz": "123",
          "pqr": "123",
          "sample": [
              {
                  "KeyIwanttotarget": "group",
                  "abc": "123",
                  "xyz": "123"
              },
              {
                  "KeyIwanttotarget": "link",
                  "abc": "123",
                  "xyz": "123",
                  "pqr": "123",
                  "sample": [
                      {
                          "KeyIwanttotarget": "link",
                          "abc": "123",
                          "xyz": "123",
                          "pqr": "123", 
                      }
                  ]
              }
          ]
      }
  ];
  </code></pre>