title: PHP json_decode JSON_ERROR_SYNTAX
body: <p>I try to load and parse JSON file from this <a href="http://www.pureexample.com/backend/data/car-sale.json" rel="nofollow noreferrer">link</a></p>
  
  <p>But I have <code>JSON_ERROR_SYNTAX</code> problem and Invalid argument supplied for <code>foreach()</code>. Why it's happen?</p>
  
  <pre><code>[{ "Manufacturer": "Toyota", "Sold": 1200, "Month": "2012-11" }, { "Manufacturer": "Ford", "Sold": 1100, "Month": "2012-11" }, { "Manufacturer": "BMW", "Sold": 900, "Month": "2012-11" }, { "Manufacturer": "Benz", "Sold": 600, "Month": "2012-11" }, { "Manufacturer": "GMC", "Sold": 500, "Month": "2012-11" }, { "Manufacturer": "HUMMER", "Sold": 120, "Month": "2012-11" }]
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  $url = "http://www.pureexample.com/backend/data/car-sale.json";
  $url = file_get_contents($url);
  print_r($url);
  $url = stripslashes($url);
  print_r($url);
  $url = str_replace("\n", "", $url);
  print_r($url);
  $url = iconv('UTF-8', 'UTF-8//IGNORE', utf8_encode($url));
  print_r($url);
  $url = json_decode($url, true);
  // Add this switch to your code
  switch (json_last_error())
  {
      case JSON_ERROR_NONE:
          echo ' - No errors';
          break;
      case JSON_ERROR_DEPTH:
          echo ' - Maximum stack depth exceeded';
          break;
      case JSON_ERROR_STATE_MISMATCH:
          echo ' - Underflow or the modes mismatch';
          break;
      case JSON_ERROR_CTRL_CHAR:
          echo ' - Unexpected control character found';
          break;
      case JSON_ERROR_SYNTAX:
          echo ' - Syntax error, malformed JSON';
          break;
      case JSON_ERROR_UTF8:
          echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
          break;
      default:
          echo ' - Unknown error';
          break;
  }
  
  
  foreach($koyim as $data){
  echo $data['Manufacturer'];
  echo $data['Sold'];
  echo $data['Month'];
  echo "&lt;br/&gt;";
  }
  ?&gt;</code></pre>
  </div>
  </div>
  </p>