Redaxscript\Reader::loadJSON PHP Метод

loadJSON() публичный Метод

load json from url
С версии: 3.0.0
public loadJSON ( string $url = null, boolean $assoc = true ) : Reader
$url string
$assoc boolean
Результат Reader
    public function loadJSON($url = null, $assoc = true)
    {
        $content = $this->load($url);
        $this->_assoc = $assoc;
        $this->_dataArray = json_decode($content, $this->_assoc);
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * adminPanelNotification
  *
  * @since 3.0.0
  *
  * @return array
  */
 public static function adminPanelNotification()
 {
     $output = [];
     $reader = new Reader();
     $aliasFilter = new Filter\Alias();
     $version = $aliasFilter->sanitize(Language::get('version', '_package'));
     /* load result */
     $urlVersion = 'http://service.redaxscript.com/version/' . $version;
     $urlNews = 'http://service.redaxscript.com/news/' . $version;
     $resultVersion = $reader->loadJSON($urlVersion)->getArray();
     $resultNews = $reader->loadJSON($urlNews)->getArray();
     /* merge as needed */
     if (is_array($resultVersion)) {
         $output = array_merge_recursive($output, $resultVersion);
     }
     if (is_array($resultNews)) {
         $output = array_merge_recursive($output, $resultNews);
     }
     return $output;
 }
All Usage Examples Of Redaxscript\Reader::loadJSON