0

Any help will be appreciated

<?php 
    $jsonobj = '{
      "status": "1",
      "receiver_account": "8",
      "USD_amount": "1.670",
      "fee_in_USD": "0.000",
      "PKR_amount": "280",
      "fee_in_PKR": "0",
      "USD_amount_with_fee": "1.670",
      "PKR_amount_with_fee": "280",
      "trx_website": "website.com",
      "transaction_id": "2JW9651118P",
      "trx_date": "25-03-2020 9:13:48 PM",
      "order_id": "12345678",
      "addi_info": "Test Payment",
      "sender_details": "Fund Received From 161919",
      "trx_details": "$1.67 Receive against TID: '2JW9651118P' "
    }';
    json_decode($jsonobj);
    var_dump($jsonobj);
?>
Mech
  • 3,952
  • 2
  • 14
  • 25
  • you are opening your `jsonobj` with a single quote (`'`) then using another within the json which ends up closing `jsonobj` before it should. – Mech Sep 25 '20 at 05:31
  • 1
    Just change `TID: '2JW9651118P' ` to `TID: \'2JW9651118P\' ` and read [this](https://stackoverflow.com/questions/7999148/escaping-quotation-marks-in-php) – angel.bonev Sep 25 '20 at 05:35
  • 2
    yes this is working ! thanks for your help !!@angel.bonev and @Mech – GreatIndian Sep 25 '20 at 05:41

1 Answers1

1

You need to escape the single quotes in your last field:

"trx_details": "$1.67 Receive against TID: \'2JW9651118P\' "
Sebastian Kaczmarek
  • 8,120
  • 4
  • 20
  • 38