We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 17e5c78 commit e1a265cCopy full SHA for e1a265c
core/json_api.php
@@ -36,17 +36,19 @@
36
/**
37
* Get a chunk of JSON from a given URL.
38
* @param string URL
39
- * @param string Top-level member to retrieve
40
- * @return multi JSON class structure
+ * @param string Optional top-level member to retrieve
+ * @return multi JSON class structure, false in case of non-existent member
41
*/
42
function json_url( $p_url, $p_member = null ) {
43
$t_data = url_get( $p_url );
44
$t_json = json_decode( utf8_encode($t_data) );
45
46
if( is_null( $p_member ) ) {
47
return $t_json;
48
- } else {
+ } else if( property_exists( $t_json, $p_member ) ) {
49
return $t_json->$p_member;
50
+ } else {
51
+ return false;
52
}
53
54
0 commit comments