intercettare JSON array vuoto

paolodue

Nuovo Utente
1 Dic 2012
3
0
0
Salve a tutti,

con questo codice si ottiene un array json, tutto funziona bene se l'array ritorna dei valori oppure se ci sono dei problemi di collegamento MA ma il codice non funzione se viene ritornato un array vuoto,

qualche dritta? ....ne stò uscendo pazzo :crying:



PHP:
        try {


		$url = "http://www.dominio.it/getvalore.php?&str=prova";
				
								
                if ( !$result = file_get_contents($url)) throw new Exception('Unable to load '.$url);
                if ( !$song = json_decode($result)) throw new Exception('Unable to decode JSON:<br>'.$result);
                if ( isset($song->error)) throw new Exception('Server-side API returns:<br>'.$result);




        } catch(Exception $e){
                die('<pre>Fatal Error: '.$e->getMessage().'</pre>');
        }
 

Discussioni simili