title: Fastest way to retrieve part from JSON in my case
body: <p>Now, I use <strong>strstr</strong> to get data from external JSON file. I'm not sure if it's the fastest way to do that what I want and I can't test because <strong>json_decode</strong> don't work in my code.</p>
  
  <pre><code>$before = '"THIS":"';
  $after = '","date"';
  $data = strstr(substr($url, strpos($url, $before) + strlen($before)), $after, true)
  </code></pre>
  
  <p>and with json_decode:</p>
  
  <pre><code>$address = file_get_contents('http://json.link/?something=Hello');
  $data = json_decode($address);
  echo $data-&gt;data-&gt;THIS;
  </code></pre>
  
  <p>Now, when I replace my first code with second I get:</p>
  
  <blockquote>
    <p><strong>Notice:</strong> Trying to get property of non-object</p>
  </blockquote>
  
  <p>All my code:</p>
  
  <pre><code>$text = "a lot of text";
  $text_split = array(0 =&gt; '');
  $number = 0;
  $words = explode(' ', $text);
  foreach($words as $word)
  {
      if(strlen($text_split[$number]) + strlen($word) + 1 &gt; 500)
      {
          ++$number;
          $text_split[$number] = '';
      }
      $text_split[$number] .= $word.' ';
  }
  foreach($text_split as $texts)
  {
      $text_encode = rawurlencode($texts);
      $address = file_get_contents('http://json.link/?something='.$text_encode);
      $data = json_decode($address);
      echo $data-&gt;data-&gt;THIS;
  }
  </code></pre>
  
  <p>What should in do in that case? Keep using strstr or replace all code to work with json_decode (maybe because execution time is faster?)? If the second option, how I can make json_decode work here? Thanks!</p>
  
  <p>... and sorry for bad english.</p>
  
  <p><strong>LE:</strong>
  If I replace <code>$address = file_get_contents('http://json.link/?something='.$text_encode);</code> with <code>$address = file_get_contents('http://json.link/?something=Hello');</code> I get VALID result for "Hello" text but 10 times. I guess because it's in a foreach.</p>