fork(1) download
  1. <?php
  2.  
  3. $str = '{"products":[{"product":{"title":"Product1","id":"82cbf74569427f33b97d3ffcebba9bab","formatted_price":"10.00","price":"10.00","image":"","url":"\/product1"},"quantity":"1"}],"data":{"firstname":"ffd","lastname":"dffdf","email":"3@gfgf.com","address":"\u0432\u0430\u043f\u0432\u0430\u043f\u0432","shipping_method":"All countries","payment_method":"paypal_express"},"shipping":{"method":"All countries","cost":"0.00"},"payment":"paypal","amount":"10.00","taxes":"0.00","token":"OnUIIJiNxd","gateway":"paypal_express"}';
  4.  
  5. $parsedToArray = json_decode($str, true);
  6. echo $parsedToArray['products'][0]['product']['title'];
  7.  
  8. echo "\n";
  9.  
  10. $parsedToObject = json_decode($str);
  11. echo $parsedToObject->products[0]->product->title;
Success #stdin #stdout 0.02s 23372KB
stdin
Standard input is empty
stdout
Product1
Product1