当前位置: 首页>>代码示例>>PHP>>正文


PHP array_unique函数代码示例

本文整理汇总了PHP中array_unique函数的典型用法代码示例。如果您正苦于以下问题:PHP array_unique函数的具体用法?PHP array_unique怎么用?PHP array_unique使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_unique函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _group2ldap

 /**
  * convert objects with user data to ldap data array
  * 
  * @param Tinebase_Model_FullUser  $_user
  * @param array                    $_ldapData  the data to be written to ldap
  */
 protected function _group2ldap(Tinebase_Model_Group $_group, array &$_ldapData)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ENCRYPT ' . print_r($_ldapData, true));
     }
     if (isset($_ldapData['objectclass'])) {
         $_ldapData['objectclass'] = array_unique(array_merge($_ldapData['objectclass'], $this->_requiredObjectClass));
     }
     if (isset($_ldapData['gidnumber'])) {
         $gidNumber = $_ldapData['gidnumber'];
     } else {
         $gidNumber = $this->_getGidNumber($_group->getId());
     }
     // when we try to add a group, $_group has no id which leads to Tinebase_Exception_InvalidArgument in $this->_getGroupMetaData
     try {
         $metaData = $this->_getGroupMetaData($_group);
     } catch (Tinebase_Exception_InvalidArgument $teia) {
         $metaData = array();
     }
     if (!isset($metaData['sambasid'])) {
         $_ldapData['sambasid'] = $this->_options[Tinebase_Group_Ldap::PLUGIN_SAMBA]['sid'] . '-' . (2 * $gidNumber + 1001);
         $_ldapData['sambagrouptype'] = 2;
     }
     $_ldapData['displayname'] = $_group->name;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:31,代码来源:Samba.php

示例2: test

 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // See if user has been a tobacco user before or simultaneosly to the encounter within two years (24 months)
     $date_array = array();
     foreach ($this->getApplicableEncounters() as $encType) {
         $dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate);
         $date_array = array_merge($date_array, $dates);
     }
     // sort array to get the most recent encounter first
     $date_array = array_unique($date_array);
     rsort($date_array);
     // go through each unique date from most recent
     foreach ($date_array as $date) {
         // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
         $date = date('Y-m-d 23:59:59', strtotime($date));
         $beginMinus24Months = strtotime('-24 month', strtotime($date));
         $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months);
         // this is basically a check to see if the patient is an reported as an active smoker on their last encounter
         if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date)) {
             return true;
         } else {
             if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date)) {
                 return false;
             } else {
                 // nothing reported during this date period, so move on to next encounter
             }
         }
     }
     return false;
 }
开发者ID:katopenzz,项目名称:openemr,代码行数:30,代码来源:Denominator.php

示例3: getAllArticles

 /**
  * Get all articles and return them as array
  * @param \DataContainer
  * @return array
  */
 public function getAllArticles(\DataContainer $dc)
 {
     $user = \BackendUser::getInstance();
     $pids = array();
     $articles = array();
     // Limit pages to the user's pagemounts
     if ($user->isAdmin) {
         $objArticle = \Database::getInstance()->execute("SELECT a.id, a.pid, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid ORDER BY parent, a.sorting");
     } else {
         foreach ($user->pagemounts as $id) {
             $pids[] = $id;
             $pids = array_merge($pids, \Database::getInstance()->getChildRecords($id, 'tl_page'));
         }
         if (empty($pids)) {
             return $articles;
         }
         $objArticle = \Database::getInstance()->execute("SELECT a.id, a.pid, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid WHERE a.pid IN(" . implode(',', array_map('intval', array_unique($pids))) . ") ORDER BY parent, a.sorting");
     }
     // Edit the result
     if ($objArticle->numRows) {
         \Controller::loadLanguageFile('tl_article');
         while ($objArticle->next()) {
             $key = $objArticle->parent . ' (ID ' . $objArticle->pid . ')';
             $articles[$key][$objArticle->id] = $objArticle->title . ' (' . ($GLOBALS['TL_LANG']['tl_article'][$objArticle->inColumn] ?: $objArticle->inColumn) . ', ID ' . $objArticle->id . ')';
         }
     }
     return $articles;
 }
开发者ID:Olli,项目名称:components,代码行数:33,代码来源:Module.php

示例4: index

 function index()
 {
     $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS;
     $files = \GCore\Libs\Folder::getFiles($path, true);
     $strings = array();
     //function to prepare strings
     $prepare = function ($str) {
         /*$path = \GCore\C::get('GCORE_FRONT_PATH');
         		if(strpos($str, $path) !== false AND strpos($str, $path) == 0){
         			return '//'.str_replace($path, '', $str);
         		}*/
         $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : '';
         return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";';
     };
     foreach ($files as $file) {
         if (substr($file, -4, 4) == '.php') {
             // AND strpos($file, DS.'extensions'.DS) === TRUE){
             //$strings[] = $file;
             $file_code = file_get_contents($file);
             preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs);
             if (!empty($langs[2])) {
                 $strings = array_merge($strings, $langs[2]);
             }
         }
     }
     $strings = array_unique($strings);
     $strings = array_map($prepare, $strings);
     echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>';
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:29,代码来源:langs.php

示例5: expand_ranges

 /**
  * Assumes that value is not *, and creates an array of valid numbers that
  * the string represents.  Returns an array.
  */
 function expand_ranges($str)
 {
     if (strstr($str, ",")) {
         $arParts = explode(',', $str);
         foreach ($arParts as $part) {
             if (strstr($part, '-')) {
                 $arRange = explode('-', $part);
                 for ($i = $arRange[0]; $i <= $arRange[1]; $i++) {
                     $ret[] = $i;
                 }
             } else {
                 $ret[] = $part;
             }
         }
     } elseif (strstr($str, '-')) {
         $arRange = explode('-', $str);
         for ($i = $arRange[0]; $i <= $arRange[1]; $i++) {
             $ret[] = $i;
         }
     } else {
         $ret[] = $str;
     }
     $ret = array_unique($ret);
     sort($ret);
     return $ret;
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:30,代码来源:class.parser.php

示例6: _buildTags

 protected function _buildTags($tagString)
 {
     $new = array_unique(array_map('trim', explode(',', $tagString)));
     $out = [];
     $query = $this->_table->Tags->find()->contain('TaggedTags')->where(['Tags.tag IN' => $new]);
     $query->matching('TaggedTags', function ($q) {
         return $q->where(['TaggedTags.model' => $this->name()]);
     });
     /*
             foreach ($query as $tag){
                 debug($tag);die;
             }*/
     // Remove existing tags from the list of new tags.
     foreach ($query->extract('tag') as $existing) {
         $index = array_search($existing, $new);
         if ($index !== false) {
             unset($new[$index]);
         }
     }
     // Add existing tags.
     foreach ($query as $tag) {
         $tag['count'] = $tag['count'] + 1;
         $out[] = $tag;
     }
     // Add new tags.
     foreach ($new as $tag) {
         $out[] = $this->_table->Tags->newEntity(['tag' => $tag, 'count' => 1]);
         //$out->_joinData = [];
         //debug ($out);
     }
     return $out;
 }
开发者ID:matthiasmoritz,项目名称:cake-tag,代码行数:32,代码来源:TaggableBehavior.php

示例7: xml_tags

 /**
  * Define the repeated tags in XML file so we can set an index
  *
  * @param array $array
  * @return array
  */
 function xml_tags($array)
 {
     $repeats_temp = array();
     $repeats_count = array();
     $repeats = array();
     if (is_array($array)) {
         $n = count($array) - 1;
         for ($i = 0; $i < $n; $i++) {
             $idn = $array[$i]['tag'] . $array[$i]['level'];
             if (in_array($idn, $repeats_temp)) {
                 $repeats_count[array_search($idn, $repeats_temp)] += 1;
             } else {
                 array_push($repeats_temp, $idn);
                 $repeats_count[array_search($idn, $repeats_temp)] = 1;
             }
         }
     }
     $n = count($repeats_count);
     for ($i = 0; $i < $n; $i++) {
         if ($repeats_count[$i] > 1) {
             array_push($repeats, $repeats_temp[$i]);
         }
     }
     unset($repeats_temp);
     unset($repeats_count);
     return array_unique($repeats);
 }
开发者ID:bizkut,项目名称:mtgserver,代码行数:33,代码来源:simplexml.class.php

示例8: reindexEntities

 /**
  * Rebuild index data by entities
  *
  *
  * @param int|array $processIds
  * @return $this
  * @throws \Exception
  */
 public function reindexEntities($processIds)
 {
     $connection = $this->getConnection();
     $this->clearTemporaryIndexTable();
     if (!is_array($processIds)) {
         $processIds = [$processIds];
     }
     $parentIds = $this->getRelationsByChild($processIds);
     if ($parentIds) {
         $processIds = array_unique(array_merge($processIds, $parentIds));
     }
     $childIds = $this->getRelationsByParent($processIds);
     if ($childIds) {
         $processIds = array_unique(array_merge($processIds, $childIds));
     }
     $this->_prepareIndex($processIds);
     $this->_prepareRelationIndex($processIds);
     $this->_removeNotVisibleEntityFromIndex();
     $connection->beginTransaction();
     try {
         // remove old index
         $where = $connection->quoteInto('entity_id IN(?)', $processIds);
         $connection->delete($this->getMainTable(), $where);
         // insert new index
         $this->insertFromTable($this->getIdxTable(), $this->getMainTable());
         $connection->commit();
     } catch (\Exception $e) {
         $connection->rollBack();
         throw $e;
     }
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:40,代码来源:AbstractEav.php

示例9: lists

 public function lists($model = null, $page = 0, $templateFile = '', $order = 'id desc')
 {
     $isAjax = I('isAjax');
     $isRadio = I('isRadio');
     // 获取模型信息
     is_array($model) || ($model = $this->getModel($model));
     $list_data = $this->_get_model_list($model, $page, $order);
     if (!empty($list_data['list_data'])) {
         $coupon_ids = array_unique(getSubByKey($list_data['list_data'], 'coupon_id'));
         $map['id'] = array('in', $coupon_ids);
         $list = M('coupon')->where($map)->field('id,title')->select();
         $couponArr = makeKeyVal($list);
         foreach ($list_data['list_data'] as &$v) {
             $v['coupon_name'] = $couponArr[$v['coupon_id']];
         }
     }
     if ($isAjax) {
         $this->assign('isRadio', $isRadio);
         $this->assign($list_data);
         $this->display('ajax_lists_data');
     } else {
         $this->assign($list_data);
         $templateFile || ($templateFile = $model['template_list'] ? $model['template_list'] : '');
         $this->display($templateFile);
     }
 }
开发者ID:chenpusn,项目名称:haozhixian_bak,代码行数:26,代码来源:InviteController.class.php

示例10: __SLEGetTransport

 function __SLEGetTransport($arFields, $arCurrentUserSubscribe)
 {
     if (array_key_exists($arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_" . $arFields["EVENT_ID"] . "_N_N", $arCurrentUserSubscribe["TRANSPORT"])) {
         $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"][$arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_" . $arFields["EVENT_ID"] . "_N_N"];
     }
     if (array_key_exists($arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_all_N_N", $arCurrentUserSubscribe["TRANSPORT"])) {
         $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"][$arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_all_N_N"];
     }
     $bHasLogEventCreatedBy = CSocNetLogTools::HasLogEventCreatedBy($arFields["EVENT_ID"]);
     if ($bHasLogEventCreatedBy) {
         if ($arFields["EVENT_ID"]) {
             if (array_key_exists("U_" . $arFields["USER_ID"] . "_all_N_Y", $arCurrentUserSubscribe["TRANSPORT"])) {
                 $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"]["U_" . $arFields["USER_ID"] . "_all_N_Y"];
             } elseif (array_key_exists("U_" . $arFields["USER_ID"] . "_all_Y_Y", $arCurrentUserSubscribe["TRANSPORT"])) {
                 $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"]["U_" . $arFields["USER_ID"] . "_all_Y_Y"];
             }
         }
     }
     if (!array_key_exists($arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_" . $arFields["EVENT_ID"] . "_N_N", $arCurrentUserSubscribe["TRANSPORT"]) && !array_key_exists($arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"] . "_all_N_N", $arCurrentUserSubscribe["TRANSPORT"])) {
         if (array_key_exists($arFields["ENTITY_TYPE"] . "_0_" . $arFields["EVENT_ID"] . "_N_N", $arCurrentUserSubscribe["TRANSPORT"])) {
             $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"][$arFields["ENTITY_TYPE"] . "_0_" . $arFields["EVENT_ID"] . "_N_N"];
         } elseif (array_key_exists($arFields["ENTITY_TYPE"] . "_0_all_N_N", $arCurrentUserSubscribe["TRANSPORT"])) {
             $arTransport[] = $arCurrentUserSubscribe["TRANSPORT"][$arFields["ENTITY_TYPE"] . "_0_all_N_N"];
         } else {
             $arTransport[] = "N";
         }
     }
     $arTransport = array_unique($arTransport);
     usort($arTransport, "__SLTransportSort");
     return $arTransport;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:include.php

示例11: bind

 /**
  * 绑定角色与权限的对应关系
  * @param $roleId   角色ID
  * @param $pids 权限ID列表
  * @param $loginUser \liuxy\admin\models\AdminUser
  */
 public static function bind($roleId, $pids, $loginUser)
 {
     self::deteteAll(['role_id' => $roleId]);
     if (!empty($pids)) {
         $pids = explode(',', $pids);
         $pids = array_unique($pids);
         foreach ($pids as $pid) {
             if (!empty($pid)) {
                 $item = new RolePermission();
                 $item->isNewRecord = true;
                 $item->role_id = $roleId;
                 $item->permission_id = $pid;
                 $item->insert_by = $loginUser->username;
                 $item->insert();
                 if ($item->hasErrors()) {
                     Yii::error(VarDumper::dumpAsString($item->getErrors()), __METHOD__);
                 }
                 unset($item);
             }
         }
         /**
          * 清理角色下所对应用户的权限
          */
         foreach (AdminUserRole::find()->where(['role_id' => $roleId])->all() as $userRole) {
             AdminUser::clearPermission($userRole['user_id']);
         }
     }
 }
开发者ID:highestgoodlikewater,项目名称:yii2-liuxy-admin,代码行数:34,代码来源:RolePermission.php

示例12: get_products_in_category

 /**
  * Get all product ids in a category (and its children)
  *
  * @param  int $category_id
  * @return array
  */
 public function get_products_in_category($category_id)
 {
     $term_ids = get_term_children($category_id, 'product_cat');
     $term_ids[] = $category_id;
     $product_ids = get_objects_in_term($term_ids, 'product_cat');
     return array_unique(apply_filters('woocommerce_report_sales_by_category_get_products_in_category', $product_ids, $category_id));
 }
开发者ID:dabodude,项目名称:woocommerce,代码行数:13,代码来源:class-wc-report-sales-by-category.php

示例13: check

 /**
  * {@inheritDoc}
  */
 public function check($value, $schema = null, JsonPointer $path = null, $i = null)
 {
     // Verify minItems
     if (isset($schema->minItems) && count($value) < $schema->minItems) {
         $this->addError($path, "There must be a minimum of " . $schema->minItems . " items in the array", 'minItems', array('minItems' => $schema->minItems));
     }
     // Verify maxItems
     if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
         $this->addError($path, "There must be a maximum of " . $schema->maxItems . " items in the array", 'maxItems', array('maxItems' => $schema->maxItems));
     }
     // Verify uniqueItems
     if (isset($schema->uniqueItems) && $schema->uniqueItems) {
         $unique = $value;
         if (is_array($value) && count($value)) {
             $unique = array_map(function ($e) {
                 return var_export($e, true);
             }, $value);
         }
         if (count(array_unique($unique)) != count($value)) {
             $this->addError($path, "There are no duplicates allowed in the array", 'uniqueItems');
         }
     }
     // Verify items
     if (isset($schema->items)) {
         $this->validateItems($value, $schema, $path, $i);
     }
 }
开发者ID:rtucek,项目名称:json-schema,代码行数:30,代码来源:CollectionConstraint.php

示例14: PMA_recursive_extract

/**
 * copy values from one array to another, usually from a superglobal into $GLOBALS
 *
 * @uses    $GLOBALS['_import_blacklist']
 * @uses    preg_replace()
 * @uses    array_keys()
 * @uses    array_unique()
 * @uses    stripslashes()
 * @param   array   $array      values from
 * @param   array   $target     values to
 * @param   boolean $sanitize   prevent importing key names in $_import_blacklist
 */
function PMA_recursive_extract($array, &$target, $sanitize = true)
{
    if (!is_array($array)) {
        return false;
    }
    if ($sanitize) {
        $valid_variables = preg_replace($GLOBALS['_import_blacklist'], '', array_keys($array));
        $valid_variables = array_unique($valid_variables);
    } else {
        $valid_variables = array_keys($array);
    }
    foreach ($valid_variables as $key) {
        if (strlen($key) === 0) {
            continue;
        }
        if (is_array($array[$key])) {
            // there could be a variable coming from a cookie of
            // another application, with the same name as this array
            unset($target[$key]);
            PMA_recursive_extract($array[$key], $target[$key], false);
        } else {
            $target[$key] = $array[$key];
        }
    }
    return true;
}
开发者ID:alecbenson,项目名称:TurnoutWeb-Patches,代码行数:38,代码来源:grab_globals.lib.php

示例15: afterSave

 protected function afterSave($resultRecords, $occur_date)
 {
     //     	\DB::enableQueryLog();
     $tankDataValue = TankDataValue::getTableName();
     $tank = Tank::getTableName();
     $columns = [\DB::raw("sum(BEGIN_VOL) \tas\tBEGIN_VOL"), \DB::raw("sum(END_VOL) \t\t\tas\tEND_VOL"), \DB::raw("sum(BEGIN_LEVEL) \t\tas\tBEGIN_LEVEL"), \DB::raw("sum(END_LEVEL) \t\tas\tEND_LEVEL"), \DB::raw("sum(TANK_GRS_VOL) \t\tas\tGRS_VOL"), \DB::raw("sum(TANK_NET_VOL) \t\tas\tNET_VOL"), \DB::raw("sum(AVAIL_SHIPPING_VOL) as\tAVAIL_SHIPPING_VOL")];
     $attributes = ['OCCUR_DATE' => $occur_date];
     $storage_ids = [];
     foreach ($resultRecords as $mdlName => $records) {
         //     		$mdl = "App\Models\\".$mdlName;
         //     		$mdlRecords = $mdl::with('Tank')->whereIn();
         foreach ($records as $mdlRecord) {
             $storageID = $mdlRecord->getStorageId();
             if ($storageID) {
                 $storage_ids[] = $storageID;
             }
         }
     }
     $storage_ids = array_unique($storage_ids);
     foreach ($storage_ids as $storage_id) {
         $values = TankDataValue::join($tank, function ($query) use($tankDataValue, $tank, $storage_id) {
             $query->on("{$tank}.ID", '=', "{$tankDataValue}.TANK_ID")->where("{$tank}.STORAGE_ID", '=', $storage_id);
         })->whereDate('OCCUR_DATE', '=', $occur_date)->select($columns)->first();
         $attributes['STORAGE_ID'] = $storage_id;
         $values = $values->toArray();
         $values['STORAGE_ID'] = $storage_id;
         $values['OCCUR_DATE'] = $occur_date;
         StorageDataValue::updateOrCreate($attributes, $values);
     }
     //     	\Log::info(\DB::getQueryLog());
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:31,代码来源:StorageController.php


注:本文中的array_unique函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。