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


PHP array_intersect函数代码示例

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


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

示例1: onSearch

 /** 1.5 **/
 public function onSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $plugin = JPluginHelper::getPlugin('search', 'easyblog');
     $params = EB::registry($plugin->params);
     if (!plgSearchEasyblog::exists()) {
         return array();
     }
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchEasyblog::onContentSearchAreas()))) {
             return array();
         }
     }
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $result = plgSearchEasyblog::getResult($text, $phrase, $ordering);
     if (!$result) {
         return array();
     }
     // require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php' );
     foreach ($result as $row) {
         $row->section = plgSearchEasyblog::getCategory($row->category_id);
         $row->section = JText::sprintf('PLG_EASYBLOG_SEARCH_BLOGS_SECTION', $row->section);
         $row->href = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id);
         $blog = EB::table('Blog');
         $blog->bind($row);
         if ($blog->getImage()) {
             $row->image = $blog->getImage('frontpage');
         }
     }
     return $result;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:easyblog.php

示例2: onContentSearch

 /**
  * Search content (articles).
  * The SQL must return the following fields that are used in a common display
  * routine: href, title, section, created, text, browsernav.
  *
  * @param   string  $text      Target search string.
  * @param   string  $phrase    Matching option (possible values: exact|any|all).  Default is "any".
  * @param   string  $ordering  Ordering option (possible values: newest|oldest|popular|alpha|category).  Default is "newest".
  * @param   mixed   $areas     An array if the search it to be restricted to areas or null to search all areas.
  *
  * @return  array  Search results.
  *
  * @since   1.6
  */
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db = JFactory::getDbo();
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     $limit = $this->params->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $rows = array();
     //Search Contents.
     if ($limit > 0) {
         switch ($phrase) {
             case 'exact':
                 $text = $db->quote('%' . $db->escape($text, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = 'a.vocabulary LIKE ' . $text;
                 $wheres2[] = 'vocab_subject.subject LIKE ' . $text;
                 $wheres2[] = 'vocab_category.category LIKE ' . $text;
                 $where = '(' . implode(') OR (', $wheres2) . ')';
                 break;
             case 'all':
             case 'any':
             default:
                 $words = explode(' ', $text);
                 $wheres = array();
                 foreach ($words as $word) {
                     $word = $db->quote('%' . $db->escape($word, true) . '%', false);
                     $wheres2 = array();
                     $wheres2[] = 'a.vocabulary LIKE ' . $word;
                     $wheres2[] = 'vocab_subject.subject LIKE ' . $word;
                     $wheres2[] = 'vocab_category.category LIKE ' . $word;
                     $wheres[] = implode(' OR ', $wheres2);
                 }
                 $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
                 break;
         }
         switch ($ordering) {
             default:
                 $order = 'a.id DESC';
                 break;
         }
         $query = $db->getQuery(true);
         $query->clear()->select(array('a.id', 'a.vocabulary AS title', '"" AS created', 'a.vocabulary AS text', '"Content" AS section', '1 AS browsernav'))->from('#__vocab_content AS a')->innerJoin('`#__vocab_subject` AS vocab_subject ON vocab_subject.id = a.subject')->innerJoin('`#__vocab_category` AS vocab_category ON vocab_category.id = a.category')->where('(' . $where . ')')->group('a.id')->order($order);
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         $limit -= count($list);
         if (isset($list)) {
             foreach ($list as $key => $item) {
                 $list[$key]->href = JRoute::_('index.php?option=com_vocab&view=content&id=' . $item->id, false, 2);
             }
         }
         $rows = array_merge($list, $rows);
     }
     return $rows;
 }
开发者ID:brianteeman,项目名称:cam,代码行数:74,代码来源:vocab.php

示例3: canExecuteChannels

 function canExecuteChannels(array $channelNames, array $groups, $skipInputCheck = false)
 {
     foreach ($channelNames as $channel) {
         if (!array_key_exists($channel, $this->channels)) {
             return false;
         }
         // At least one match is required
         if (count(array_intersect($groups, $this->channels[$channel]['groups'])) == 0) {
             return false;
         }
         // Checking against input if required (note that unlike normal groups, all must match)
         foreach ($this->channels[$channel]['groups'] as $g) {
             if ($skipInputCheck) {
                 break;
             }
             if (preg_match('/\\$profilerequest\\:(\\w+)\\$/', $g, $matches)) {
                 for ($i = 1, $count_matches = count($matches); $i < $count_matches; $i++) {
                     if (empty($_REQUEST[$matches[$i]])) {
                         return false;
                     } else {
                         $tocheck = str_replace($matches[0], $_REQUEST[$matches[$i]], $g);
                         if (!in_array($tocheck, $groups)) {
                             return false;
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
开发者ID:railfuture,项目名称:tiki-website,代码行数:31,代码来源:channellib.php

示例4: run

 /**
  * @param mixed $content
  */
 public function run(&$content)
 {
     /**
      *  //真不知道说什么好。。。
      *      这里      原因是tp 不能把tag放在项目配置中,只能放在common中,而common模块先于install 初始化
      *     so。。。。。
      *
      */
     if (C('DB_TYPE') == 'GreenCMS_DB_TYPE') {
     } else {
         if (isset($_GET['m']) && strtolower($_GET['m']) == 'install') {
             return;
         }
         $data = S('hooks');
         if (!$data) {
             $hooks = M('Hooks')->getField('name,addons');
             foreach ($hooks as $key => $value) {
                 if ($value) {
                     $map['status'] = 1;
                     $names = explode(',', $value);
                     $map['name'] = array('IN', $names);
                     $data = M('Addons')->where($map)->getField('id,name');
                     if ($data) {
                         $addons = array_intersect($names, $data);
                         Hook::add($key, $addons);
                     }
                 }
             }
             S('hooks', Hook::get());
         } else {
             Hook::import($data, false);
         }
     }
 }
开发者ID:zachdary,项目名称:GreenCMS,代码行数:37,代码来源:InitHookBehavior.class.php

示例5: sortOutProtected

	/**
	 * Sort out protected archives
	 * @param array
	 * @return array
	 */
	protected function sortOutProtected($arrArchives)
	{
		if (BE_USER_LOGGED_IN || !is_array($arrArchives) || empty($arrArchives))
		{
			return $arrArchives;
		}

		$this->import('FrontendUser', 'User');
		$objArchive = $this->Database->execute("SELECT id, protected, groups FROM tl_news_archive WHERE id IN(" . implode(',', array_map('intval', $arrArchives)) . ")");
		$arrArchives = array();

		while ($objArchive->next())
		{
			if ($objArchive->protected)
			{
				if (!FE_USER_LOGGED_IN)
				{
					continue;
				}

				$groups = deserialize($objArchive->groups);

				if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups)))
				{
					continue;
				}
			}

			$arrArchives[] = $objArchive->id;
		}

		return $arrArchives;
	}
开发者ID:narrenfrei,项目名称:core,代码行数:38,代码来源:ModuleNews.php

示例6: initialize

 /**
  * initialize method
  *
  * Merge settings and set Config.language to a valid locale
  *
  * @return void
  * @access public
  */
 function initialize(&$Controller, $config = array())
 {
     App::import('Vendor', 'Mi.MiCache');
     $lang = MiCache::setting('Site.lang');
     if (!$lang) {
         if (!defined('DEFAULT_LANGUAGE')) {
             return;
         }
         $lang = DEFAULT_LANGUAGE;
     } elseif (!defined('DEFAULT_LANGUAGE')) {
         define('DEFAULT_LANGUAGE', $lang);
     }
     Configure::write('Config.language', $lang);
     App::import('Core', 'I18n');
     $I18n =& I18n::getInstance();
     $I18n->domain = 'default_' . $lang;
     $I18n->__lang = $lang;
     $I18n->l10n->get($lang);
     if (!empty($Controller->plugin)) {
         $config['plugins'][] = Inflector::underscore($Controller->plugin);
     }
     if (!empty($config['plugins'])) {
         $plugins = array_intersect(MiCache::mi('plugins'), $config['plugins']);
         $Inst = App::getInstance();
         foreach ($plugins as $path => $name) {
             $Inst->locales[] = $path . DS . 'locale' . DS;
         }
     }
 }
开发者ID:hiromi2424,项目名称:mi,代码行数:37,代码来源:language.php

示例7: getOnlineUsersInfo

function getOnlineUsersInfo($sUserId, $bInit)
{
    global $aXmlTemplates;
    $aSaved = getSavedUsers();
    $aActive = getActiveUsers($sUserId);
    $aFriends = getFriends($sUserId);
    saveUsers($aActive);
    $sContents = "";
    if ($bInit) {
        $aFullUsers = array_unique(array_merge($aActive['online'], $aFriends));
    } else {
        $aFullUsers = array_diff($aActive['online'], $aSaved['online'], $aFriends);
        $aNewOfflineUsers = array_intersect($aSaved['online'], $aActive['offline']);
        $aNewOnlineUsers = array_intersect($aSaved['offline'], $aActive['online'], $aFriends);
        for ($i = 0; $i < count($aNewOfflineUsers); $i++) {
            $sContents .= parseXml($aXmlTemplates['user'], $aNewOfflineUsers[$i], FALSE_VAL);
        }
        for ($i = 0; $i < count($aNewOnlineUsers); $i++) {
            $sContents .= parseXml($aXmlTemplates['user'], $aNewOnlineUsers[$i], TRUE_VAL);
        }
    }
    $rResult = getUsersMedia($aFullUsers);
    if ($rResult != null) {
        for ($i = 0; $i < mysql_num_rows($rResult); $i++) {
            $aUser = mysql_fetch_assoc($rResult);
            $aUserInfo = getUserInfo($aUser['ID']);
            $sOnline = in_array($aUser['ID'], $aActive['online']) ? TRUE_VAL : FALSE_VAL;
            $sFriend = in_array($aUser['ID'], $aFriends) ? TRUE_VAL : FALSE_VAL;
            $sMusic = $aUser['CountMusic'] > 0 ? TRUE_VAL : FALSE_VAL;
            $sVideo = $aUser['CountVideo'] > 0 ? TRUE_VAL : FALSE_VAL;
            $sContents .= parseXml($aXmlTemplates['user'], $aUser['ID'], $aUserInfo['nick'], $aUserInfo['sex'], $aUserInfo['age'], $aUserInfo['photo'], $aUserInfo['profile'], $sOnline, $sFriend, $sMusic, $sVideo);
        }
    }
    return makeGroup($sContents, "users");
}
开发者ID:dalinhuang,项目名称:shopexts,代码行数:35,代码来源:functions.inc.php

示例8: testEnumConnectionObjects

 /**
  * testEnumConnectionObjects method
  *
  * @return void
  */
 public function testEnumConnectionObjects()
 {
     $sources = ConnectionManager::enumConnectionObjects();
     $this->assertTrue(count($sources) >= 1);
     $connections = array('default', 'test', 'test');
     $this->assertTrue(count(array_intersect(array_keys($sources), $connections)) >= 1);
 }
开发者ID:Oswald-Dsa,项目名称:cakephp-ex,代码行数:12,代码来源:ConnectionManagerTest.php

示例9: info

 public function info()
 {
     global $gb_json_api;
     $php = '';
     if (!empty($gb_json_api->query->controller)) {
         return $gb_json_api->controller_info($gb_json_api->query->controller);
     } else {
         $dir = gb_json_api_dir();
         if (file_exists("{$dir}/gb_json-api.php")) {
             $php = file_get_contents("{$dir}/gb_json-api.php");
         } else {
             // Check one directory up, in case json-api.php was moved
             $dir = dirname($dir);
             if (file_exists("{$dir}/gb_json-api.php")) {
                 $php = file_get_contents("{$dir}/gb_json-api.php");
             }
         }
         if (preg_match('/^\\s*Version:\\s*(.+)$/m', $php, $matches)) {
             $version = $matches[1];
         } else {
             $version = '(Unknown)';
         }
         $active_controllers = explode(',', get_option('gb_json_api_controllers', 'core'));
         $controllers = array_intersect($gb_json_api->get_controllers(), $active_controllers);
         return array('gb_json_api_version' => $version, 'controllers' => array_values($controllers));
     }
 }
开发者ID:simplon-emmanuelD,项目名称:Simplon-INESS,代码行数:27,代码来源:core.php

示例10: doGetProductIds

 function doGetProductIds()
 {
     if (!$this->filteringOnWheelSide() && !$this->filteringOnVehicleSide()) {
         return $this->productIdsMatchingVehicleSelection();
     }
     $finder = new VF_Wheeladapter_Finder();
     if ($this->filteringOnWheelSide() && $this->filteringOnVehicleSide()) {
         $productIds = $finder->getProductIds($this->wheelBolt(), $this->vehicleBolt());
     } else {
         if (!$this->filteringOnWheelSide()) {
             $productIds = $finder->getProductIds(null, $this->vehicleBolt());
         } else {
             if (!$this->filteringOnVehicleSide()) {
                 $productIds = $finder->getProductIds($this->wheelBolt(), null);
                 if ($this->wrappedFlexibleSearch->hasRequest()) {
                     $productIds = array_intersect($productIds, $this->productIdsMatchingVehicleSelection());
                 }
             }
         }
     }
     if (array() == $productIds) {
         return array(0);
     }
     return $productIds;
 }
开发者ID:xiaoguizhidao,项目名称:autotech_design,代码行数:25,代码来源:FlexibleSearch.php

示例11: plgSearchEvents

function plgSearchEvents($text, $phrase = '', $ordering = '', $areas = null)
{
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchEventsAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'events');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $events = KService::get('com://admin/calendar.model.events')->sort('tbl.start_date')->direction('ASC')->limit($limit)->search($text)->getList();
    $return = array();
    foreach ($events as $event) {
        if (searchHelper::checkNoHTML($event, $text, array('title', 'description'))) {
            $event->text = $event->description;
            $event->origin = 'events';
            $event->href = 'index.php?option=com_calendar&view=event&id=' . $event->id . '&slug=' . $event->slug;
            $event->section = JText::_('Events');
            $return[] = $event->getData();
        }
    }
    return $return;
}
开发者ID:JSWebdesign,项目名称:intranet-platform,代码行数:29,代码来源:events.php

示例12: p3_plugin_disclaimers

    function p3_plugin_disclaimers($profile)
    {
        $disclaimed_plugins = array('jetpack', 'wordpress-seo');
        if ($detected = array_intersect($disclaimed_plugins, $profile->get_raw_plugin_list())) {
            ?>
			<div class="updated inline">
				<p><?php 
            printf(__('Some plugins may show artificially high results.  <a href="%s">More info</a>', 'p3-profiler'), admin_url('tools.php?page=p3-profiler&p3_action=help#q17'));
            ?>
</p>
				<ul style="list-style: initial; margin-left: 1.5em;">
				<?php 
            foreach ($detected as $plugin) {
                ?>
					<li><?php 
                echo $profile->get_plugin_name($plugin);
                ?>
</li>
				<?php 
            }
            ?>
				</ul>
			</div>
			<?php 
        }
    }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:26,代码来源:p3-profiler.php

示例13: methods

 /** @test */
 public function methods()
 {
     $needed_methods = array('toArray');
     $this->assertThat(array_unique(get_class_methods(__NAMESPACE__ . '\\DbIterator')), new \PHPUnit_Framework_Constraint_Callback(function ($class_methods) use($needed_methods) {
         return $needed_methods === array_intersect($needed_methods, $class_methods);
     }));
 }
开发者ID:neoparla,项目名称:dbescaper,代码行数:8,代码来源:DbIteratorTest.php

示例14: matchExtendsSingle

 protected function matchExtendsSingle($single, &$out_origin, &$out_rem)
 {
     $counts = array();
     foreach ($single as $part) {
         if (!is_string($part)) {
             return false;
         }
         // hmm
         if (isset($this->extendsMap[$part])) {
             foreach ($this->extendsMap[$part] as $idx) {
                 $counts[$idx] = isset($counts[$idx]) ? $counts[$idx] + 1 : 1;
             }
         }
     }
     foreach ($counts as $idx => $count) {
         list($target, $origin) = $this->extends[$idx];
         // check count
         if ($count != count($target)) {
             continue;
         }
         // check if target is subset of single
         if (array_diff(array_intersect($single, $target), $target)) {
             continue;
         }
         $out_origin = $origin;
         $out_rem = array_diff($single, $target);
         return true;
     }
     return false;
 }
开发者ID:mostafiz93,项目名称:PrintfScanf,代码行数:30,代码来源:scss.inc.php

示例15: getRecordForStore

 protected function getRecordForStore($values)
 {
     $value = array();
     if ($values['type'] == 'text' || $values['type'] == 'textarea' || $values['type'] == 'date') {
         $default = $values['default'];
     } else {
         $default = array_intersect($values['values']['default'], array_keys($values['values']['options']));
         if ($values['type'] == 'radio') {
             $default = $default[0];
         }
     }
     if ($values['type'] == 'select') {
         $values['size'] = 1;
     }
     $recordForStore['title'] = $values['title'];
     $recordForStore['description'] = $values['description'];
     $recordForStore['sql'] = $values['sql'];
     $recordForStore['type'] = $values['type'];
     $recordForStore['validate_func'] = $values['validate_func'];
     $recordForStore['additional_fields'] = array('sql' => intval($values['sql']), 'sql_type' => $values['sql_type'], 'size' => $values['size'], 'default' => $default, 'options' => $values['values']['options'], 'cols' => $values['cols'], 'rows' => $values['rows']);
     $default_fields = array('type' => 1, 'default' => 1, 'values' => 1, 'size' => 1, 'title' => 1, 'description' => 1, 'validate_func' => 1, 'sql' => 1, 'sql_type' => 1, 'cols' => 1, 'rows' => 1);
     foreach ($values as $k => $v) {
         if (!isset($default_fields[$k]) && $k[0] != '_') {
             $recordForStore['additional_fields'][$k] = $v;
         }
     }
     return $recordForStore;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:28,代码来源:CustomField.php


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