title: How to remove double quotes from json converted through php queries
body: <p>I have a string in a json format, but this is giving invalid json format as i am querying it via php loops</p>
  
  <pre><code>{"a":"" works our â€˜Tâ€™ logo into an intricately perforated pattern. logo â€” pattern. Height: .36"" (.9 cm) Length: .29"" (.7 cm) " " }
  </code></pre>
  
  <p>I need the output as </p>
  
  <pre><code>   {"a":"works our â€˜Tâ€™ logo into an intricately perforated pattern. logo â€ pattern. Height: .36 (.9 cm) Length: .29 (.7 cm)"}
  </code></pre>
  
  <p>(i think this should be the correct format)</p>
  
  <p>I have tried <strong>str_replace</strong> ,but it is removing quotes from the start and end as well, and <strong>trim()</strong> method also removed all the double quotes in the string. </p>
  
  <pre><code>&lt;?php
  $a = "" works our â€˜Tâ€™ logo into an intricately perforated pattern. logo â€” pattern. Height: .36"" (.9 cm) Length: .29"" (.7 cm) " " ;
  
  echo str_replace('"',"",$a);
  
  
  ?&gt;
  </code></pre>
  
  <p>and i m getting this error: 
  <strong>Line : 2,   Error type : 4
  Message : syntax error, unexpected 'works' (T_STRING)</strong></p>
  
  <p>Note: this value is fetched from the DB and i need it to post to some api so that they can get all the values from our api. and i really dnt want to make any changes in our database or our backend from where this value is coming.</p>
  
  <p>Hint or little solution would help i think. </p>
  
  <p>//To highlight more on what i m exactly doing with the json
  //see the below code.</p>
  
  <pre><code>&lt;?php
  ini_set('max_execution_time', 0);
  require __DIR__ . '/app/Mage.php';
  umask(0);
  Mage::app();
  
  
   $collection = Mage::getModel('catalog/product')-&gt;getCollection()-&gt;addAttributeToSelect("name");
  
  
  foreach($collection as $product){
  
    $product_name = strip_tags($product-&gt;getName()); //get name of the product
  
  
  $result = array();
  foreach ($products as $product1) {
      $label = array_reduce(
          $someattrbute,
          function ($carry, $item) use ($product1) {
              return $carry . $product1-&gt;getAttributeText($item) . ' ';
          },
          ''
      );
      $result[trim($label)] = $product1-&gt;getQty();
  }
   $product_sizeandquantity = json_encode($result); //result
  
  $products_data.= "{";
  
      $products_data.= '"product_name"'.":".'"'.$product_name.'",';
     $products_data.= '"product_stock"'.":".'['.$product_sizeandquantity.'],';
  
      $products_data.= "},";
  
    $products_data = rtrim($products_data, ',');
  
    $products_data.= "]";
  
  //echo $products_data;
  
      $url = 'https://www.yourdomain.com/products';
      $api_key = 'mykey'; 
      $sec_key = 'secretkey';
  
    $data='scapi_key='.urlencode($api_key).'&amp;scsecret_key='.urlencode($sec_key)."&amp;products=".urlencode($products_data);
  
   //echo $data;
  
  
  $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");  
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
      curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
       'Content-Type: application/x-www-form-urlencoded')                                                                      
      );
  
      $response = curl_exec($ch);
      curl_close($ch);
      $arr = json_decode($response, true);
      echo $arr;
  
  ?&gt;
  </code></pre>
  
  <p>And this is the json i m getting and this is only for one product, but there are many,as it is foreach loop:</p>
  
  <pre><code>[{"product_name":"Flats", "product_stock":[{"38":"1.0000"}]}]
  </code></pre>
  
  <p>I think that this is valid json, but still want to know what can be done to pass it through the post request of curl in the above code, as error shows that its a json invalid error.</p>
  
  <p><strong>Note</strong>: Some of the products also has the height and sizes and content containing double quotes as shown above.</p>