Reputation: 475
$ch = curl_init('http://www.somesite.com/project/User?id=1&&user=MYUSER');
$result = curl_exec($ch);
print $result;
curl_close($ch);
$json=json_decode($result,true);
print "-->".$json;
print "------>".$json['PASSWORD'];`
The output I get is:
-->1
------>
What is the "1" that is appended towards the end? How do i solve it?
Upvotes: 0
Views: 1618
Reputation: 1473
My guess is you're using curl incorrectly. You should set CURLOPT_RETURNTRANSFER option to true:
$ch = curl_init('http://www.somesite.com/project/User?id=1&&user=MYUSER');
curl_setopt( CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
print $result;
curl_close($ch);
$json=json_decode($result,true);
Otherwise you're just printing everything into stdout.
Upvotes: 1
Reputation: 70540
$result = curl_exec($ch);
=> $result = true
, you forgot:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Upvotes: 6