PHP Code Samples From Stack Overflow
How to parse json response from CURL
https://stackoverflow.com/questions/17016506/how-to-parse-json-response-from-curl
$result = '{"Cancelled":false,"MessageID":"402f481b-c420-481f-b129-7b2d8ce7cf0a","Queued":false,"SMSError":2,"SMSIncomingMessages":null,"Sent":false,"SentDateTime":"\/Date(-62135578800000-0500)\/"}';
$json = json_decode($result, true);
print_r($json);
$json is an array as shown below
Array
(
[Cancelled] =>
[MessageID] => 402f481b-c420-481f-b129-7b2d8ce7cf0a
[Queued] =>
[SMSError] => 2
[SMSIncomingMessages] =>
[Sent] =>
[SentDateTime] => /Date(-62135578800000-0500)/
)
Then treat
$json
variable as an array:echo $json['MessageID'];
echo $json['SMSError'];
// other stuff
Convert CSV to JSON using PHP
https://stackoverflow.com/questions/28118101/convert-csv-to-json-using-php
$file="1_23.csv";
$csv= file_get_contents($file);
$array = array_map("str_getcsv", explode("\n", $csv));
$json = json_encode($array);
print_r($json);
No comments:
Post a Comment