0
$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?

1
  • try print_r instead of print for your $json array Commented Mar 5, 2013 at 17:51

2 Answers 2

6

$result = curl_exec($ch); => $result = true, you forgot:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.