Category : json

Hi i have a section of an XML out put that contains <Question type="2" text="Which one of the following area codes is associated with you?"> <Answer correct="false">606</Answer> <Answer correct="false">859</Answer> <Answer correct="false">616</Answer> <Answer correct="false">614/380</Answer> <Answer correct="false">812</Answer> <Answer correct="true">502</Answer> <Answer correct="false">810</Answer> <Answer correct="false">740</Answer> <Answer correct="false">248</Answer> <Answer correct="false">None of the above</Answer> </Question> I am using this to parse ..

Read more

im trying to access the ID and SENT from this JSON but is not working for me. UPDATED $json = ‘{ "response": { "sent": true, "message": "Sent to 57304", "id": "gBEGVzBChXFYAgmcOrfFpGem8qw" } }’; json_decode($json); $id=$json->id; $sent=$json->sent; echo "</br> id:".$id."</br>"; echo "</br> sent:".$sent."</br>"; Sourc..

Read more

For some reason, I can’t get the value of "price" from a cookie. Here’s the cookie info. [{"label":"300 HOME ","price":150},{"label":"Yes, my phone line is (1234567890)","price":40},{"label":"internet 2","price":0},{"price":-25}] And here’s the code I’m using. What am I doing wrong? <?php $cookie = $_COOKIE["MonthlyOptions"]; $obj = json_decode($cookie); print $obj->{‘price’}; ?> Sourc..

Read more

I am fetching JSON data with CORS and I am getting the JSON data in my console successfully. Now I want to display the fetched data with PHP. What are the next steps after the code below to get the fetched data into PHP? <script> fetch(“http://localhost:8000/get_users.php”, { method: ‘post’, credentials: ‘include’ }).then(response => { return ..

Read more

I have this php code as I am trying to execute a particular function in my php project, I code the implementation correct but I ran into a small problem. <?php echo ‘<script type="text/javascript">’; $data = array( ‘base’ => ‘USD’, ‘alter’ => ‘ETH’, ‘data’ => array() ); foreach ($cryptos as $row) { $sy = $row["symbol"]; ..

Read more

Hii i’m trying to getting json file content from url using php but it returns null value. $share = json_decode(file_get_contents("https://example.com/path/to/file/user/$id.json"), true); and json file format is like that {"file":{"status":"publish","mime":"application/rar","downloads":1}}. What wrong with my code when i debug $share it returns null. In error log it says PHP Warning: file_get_contents(): https:// wrapper is disabled in the ..

Read more

I have an array as below: And I have converted it to JSON with following code: json_encode($finalResult, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); The result contains n and spaces. How they are created? and How I can remove them? "[n {n "trackingId": "lcJFs21zUPgm",n "date": "3792-09-28 16:34:54",n "status": "success",n "statusCode": "6",n "statusDescription": "test"n },n {n "trackingId": "lcJFs21zUPgo",n ..

Read more