json - Simplify php curl code -


i trying json url. code working think better. (remove json_decode or json_encode). right have: (edit: still want use curl)

<?php  $curl = curl_init('url');   curl_setopt($curl, curlopt_url, 'url');  curl_setopt($curl, curlopt_returntransfer, true);   $result = curl_exec($curl);   curl_close($curl);   $data = json_decode($result, true);   echo json_encode($data["name"]);   ?> 

you can try this:

$data = json_decode(file_get_contents('php://input')); print_r($data); 

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -