title: How to find substring that contains JSON data?
body: <p>I'm trying to find a JSON string inside a string, with PHP.</p>
  
  <p>So if a string is entirely JSON, PHP can parse it like this:</p>
  
  <pre><code>&lt;?php
  $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
  
  var_dump(json_decode($json));
  var_dump(json_decode($json, true));
  
  ?&gt;
  </code></pre>
  
  <p>But what if I have a string like</p>
  
  <pre><code>$str = 'I have a string that contains JSON like this : {"a":1,"b":2,"c":3,"d":4,"e":5} and then string continues';
  </code></pre>
  
  <p>How can I parse JSON from this?</p>
  
  <p>Thanks !</p>
  
  <h2>Edit:</h2>
  
  <p>Thanks for all your answers. They really helped me. And I should add that in my case, the string will be in this form:</p>
  
  <pre><code>$str = 'some string and some more string [[delimiter]] json={"a":1,"b":2}';
  </code></pre>
  
  <p>and, I'm not the downvoter :)</p>