Beispiel #1
0
 /**
  * plug list
  */
 public function indexAction()
 {
     $plugNewAll = array();
     $plugModel = new \Admin\Model\plugModel();
     $plugLocAll = $plugModel->getPlugins();
     $plugLocAll = is_array($plugLocAll) ? $plugLocAll : array();
     $plugDb = db()->table('plugs')->getAll()->done();
     foreach ($plugDb as $k => $v) {
         $plugAll[$v['name']] = $v;
         $plugAll[$v['name']]['isInstall'] = true;
     }
     $array1 = array("a" => array(1, 2, 3), "b" => "brown", "c" => "blue", "red");
     //$array2 = array("a" => "green", "yellow", "red");
     //$result = array_diff_assoc($array1, $array2);
     $arr = arrayDiffAssoc2Deep($plugLocAll, $plugAll);
     if ($arr) {
         $plugAll = array_merge($plugAll, $arr);
     }
     $config = new \Admin\Model\webConfigModel();
     $data = array('plugAll' => $plugAll, 'plugHooKConfig' => C("plugs_hook"));
     $this->getView()->assign($data);
     return $this->getView()->display();
 }
Beispiel #2
0
/**
 * 二维数组  array_diff_assoc
 * @param $array1
 * @param $array2
 * @return array
 */
function arrayDiffAssoc2Deep($array1, $array2)
{
    $ret = array();
    foreach ($array1 as $k => $v) {
        if (!isset($array2[$k])) {
            $ret[$k] = $v;
        } else {
            if (is_array($v) && is_array($array2[$k])) {
                $ret[$k] = arrayDiffAssoc2Deep($v, $array2[$k]);
            } else {
                if ($v != $array2[$k]) {
                    $ret[$k] = $v;
                } else {
                    unset($array1[$k]);
                }
            }
        }
    }
    return $ret;
}