title: php - Explode array into a key->value array
body: <p>I have the following string:</p>
  
  <blockquote>
    <p>Name_Location_Telephone_break_Name_Location_Telephone_break_Name_Location_Telephone_break_Name_Location_Telephone_break_ </p>
  </blockquote>
  
  <p>I got this from a cURL of an HTML page using DOM.</p>
  
  <p>My final result must be a JSON file like:</p>
  
  <pre><code>Shop 1: { name: "example", location: "example", telephone: "0123"}
  Shop 2: { name: "example", location: "example", telephone: "0123"}
  </code></pre>
  
  <p>But I know that first I have to split the string, I tried this</p>
  
  <pre><code>$shops = explode("break",$result);
  $values = array();
  
  foreach ($shops as $shop) {
      $values = explode("_", $shop);
      foreach($values as $value) {
          $name = $value[0];
          $location = $value[1];
          $tel = $value[2];
      }
  }
  </code></pre>
  
  <p>But it doesn't work. Can anybody help me?</p>