hi,

what am i doing wrong? tried several ways but each time i get a json.parse error.

here's the code:

Code:
function curl_file_get_contents($url) {
	$ch = curl_init();
	$timeout = 5; 
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	$file_contents = curl_exec($ch);		//curl output to string
	curl_close($ch);
	
	$jsonIterator = new RecursiveIteratorIterator (
		new RecursiveArrayIterator(json_decode($file_contents, TRUE)),
		RecursiveIteratorIterator::SELF_FIRST
	);
	
	foreach ($jsonIterator as $key => $value) {
		if(is_array($value)) {
			echo "$key:\n";
		}
		else {
			echo "$key => $value\n";
		}
	}

}
tried it also without the recursiveIterator, just a simple foreach, didn't help.

the result of the echo is sent to:

Code:
$json = json_encode(curl_file_get_contents($jsonPath));
echo $json;
..and then with ajax to the div.

Any ideas?