title: Crawling through data in JS block in PHP
body: <p>I want to find data from a webpage which stores data in Java Script block and later renders the page using those data. How to fetch such data in PHP ?<br>
  I've tried DOMXPath and DomDocument, still no luck !<br>
  Below I'm posting an example of the target page.</p>
  
  <pre><code>&lt;html&gt;
  ...
  &lt;script type="text/javascript"&gt;
  var showHeader = true;
  var Data = {
    "packageId": "120",
    "packageTitle": "West Bengal",
    "Type": "Customizable",
     "Components": [
      {
        "destination": "Darjeeling",
        "dayNum": {
          "1": {
            "sightseeings": [
              "No Sightseeing"
            ],
            "itineraries": {
              "title": "Bagdogra / New Jalpaiguri - Darjeeling",
              "description": "&lt;p&gt;Welcome to darjeeling.&lt;/p&gt;"
            }
          }
          }
        }
      ]
      };
  &lt;/script&gt;
  &lt;body&gt;
  ...
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to retrieve all those data in an associative array using PHP so I can use like <strong>$data['showHeader']</strong> or <strong>$data['data']['packageId']</strong></p>