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


PHP array_intersect_assoc函数代码示例

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


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

示例1: bulk_actions

 /**
  * Display the bulk actions dropdown.
  *
  * @since 3.1.0
  * @access public
  */
 function bulk_actions()
 {
     $screen = get_current_screen();
     if (is_null($this->_actions)) {
         $no_new_actions = $this->_actions = $this->get_bulk_actions();
         // This filter can currently only be used to remove actions.
         //$this->_actions = apply_filters( 'bulk_actions-cred' . $screen->id, $this->_actions );
         $this->_actions = array_intersect_assoc($this->_actions, $no_new_actions);
         $two = '';
     } else {
         $two = '2';
     }
     if (empty($this->_actions)) {
         return;
     }
     echo "<select name='action{$two}'>\n";
     echo "<option value='-1' selected='selected'>" . __('Bulk Actions', 'wp-cred') . "</option>\n";
     foreach ($this->_actions as $name => $title) {
         $class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
         echo "\t<option value='{$name}'{$class}>{$title}</option>\n";
     }
     echo "</select>\n";
     submit_button(__('Apply', 'wp-cred'), 'button-secondary action', false, false, array('id' => "doaction{$two}"));
     echo "\n";
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:31,代码来源:Custom_Fields_List_Table.php

示例2: context_check

 function context_check($check, $settings)
 {
     if (empty($settings)) {
         return $check;
     }
     $status = array();
     if (!is_array($this->post_types)) {
         $this->set_objects();
     }
     foreach ($this->post_types as $post_type => $post_type_settings) {
         if (isset($settings['is_singular-' . $post_type]) && $settings['is_singular-' . $post_type]) {
             $status['is_singular-' . $post_type] = is_singular($post_type);
         }
         if (isset($settings['is_archive-' . $post_type]) && $settings['is_archive-' . $post_type]) {
             $status['is_archive-' . $post_type] = is_post_type_archive($post_type);
         }
     }
     foreach ($this->taxonomies as $taxonomy => $tax_settings) {
         if (isset($settings['is_tax-' . $taxonomy]) && $settings['is_tax-' . $taxonomy]) {
             $status['is_tax-' . $taxonomy] = is_tax($taxonomy);
         }
     }
     $matched = array_intersect_assoc($settings, $status);
     if (!empty($matched)) {
         return true;
     }
     return $check;
 }
开发者ID:koopmant,项目名称:Mens-site,代码行数:28,代码来源:module.php

示例3: array_merge_recursive_unique

 /**
  *
  * Merge array two arrays recursively
  * @see testing : M/tests/MArray_test.php
  *
  * @access	public
  * @return	Merged array	array
  * @static
  *
  */
 public static function array_merge_recursive_unique($first, $second, $greedy = false)
 {
     $inter = array_intersect_assoc(array_keys($first), array_keys($second));
     # shaired keys
     # the idea next, is to strip and append from $second into $first
     foreach ($inter as $key) {
         # recursion if both are arrays
         if (is_array($first[$key]) && is_array($second[$key])) {
             $first[$key] = self::array_merge_recursive_unique($first[$key], $second[$key]);
         } else {
             if (is_array($first[$key] && !$greedy)) {
                 $first[$key][] = $second[$key];
             } else {
                 if (is_array($second[$key]) && !$greedy) {
                     $second[$key][] = $first[$key];
                     $first[$key] = $second[$key];
                 } else {
                     $first[$key] = $second[$key];
                 }
             }
         }
         unset($second[$key]);
     }
     # merge the unmatching keys onto first
     return array_merge($first, $second);
 }
开发者ID:demental,项目名称:m,代码行数:36,代码来源:MArray.php

示例4: extract_current_page

 /**
  * Extract current session page
  *
  * @param string $root_path current root path (phpbb_root_path)
  */
 function extract_current_page($root_path)
 {
     $page_array = array();
     // First of all, get the request uri...
     $script_name = !empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
     $args = !empty($_SERVER['QUERY_STRING']) ? explode('&', $_SERVER['QUERY_STRING']) : explode('&', getenv('QUERY_STRING'));
     // If we are unable to get the script name we use REQUEST_URI as a failover and note it within the page array for easier support...
     if (!$script_name) {
         $script_name = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
         $script_name = ($pos = strpos($script_name, '?')) !== false ? substr($script_name, 0, $pos) : $script_name;
         $page_array['failover'] = 1;
     }
     // Replace backslashes and doubled slashes (could happen on some proxy setups)
     $script_name = str_replace(array('\\', '//'), '/', $script_name);
     // Now, remove the sid and let us get a clean query string...
     $use_args = array();
     // Since some browser do not encode correctly we need to do this with some "special" characters...
     // " -> %22, ' => %27, < -> %3C, > -> %3E
     $find = array('"', "'", '<', '>');
     $replace = array('%22', '%27', '%3C', '%3E');
     foreach ($args as $key => $argument) {
         if (strpos($argument, 'sid=') === 0) {
             continue;
         }
         $use_args[] = str_replace($find, $replace, $argument);
     }
     unset($args);
     // The following examples given are for an request uri of {path to the phpbb directory}/adm/index.php?i=10&b=2
     // The current query string
     $query_string = trim(implode('&', $use_args));
     // basenamed page name (for example: index.php)
     $page_name = substr($script_name, -1, 1) == '/' ? '' : basename($script_name);
     $page_name = urlencode(htmlspecialchars($page_name));
     // current directory within the phpBB root (for example: adm)
     $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($root_path)));
     $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath('./')));
     $intersection = array_intersect_assoc($root_dirs, $page_dirs);
     $root_dirs = array_diff_assoc($root_dirs, $intersection);
     $page_dirs = array_diff_assoc($page_dirs, $intersection);
     $page_dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs);
     if ($page_dir && substr($page_dir, -1, 1) == '/') {
         $page_dir = substr($page_dir, 0, -1);
     }
     // Current page from phpBB root (for example: adm/index.php?i=10&b=2)
     $page = ($page_dir ? $page_dir . '/' : '') . $page_name . ($query_string ? "?{$query_string}" : '');
     // The script path from the webroot to the current directory (for example: /phpBB3/adm/) : always prefixed with / and ends in /
     $script_path = trim(str_replace('\\', '/', dirname($script_name)));
     // The script path from the webroot to the phpBB root (for example: /phpBB3/)
     $script_dirs = explode('/', $script_path);
     array_splice($script_dirs, -sizeof($page_dirs));
     $root_script_path = implode('/', $script_dirs) . (sizeof($root_dirs) ? '/' . implode('/', $root_dirs) : '');
     // We are on the base level (phpBB root == webroot), lets adjust the variables a bit...
     if (!$root_script_path) {
         $root_script_path = $page_dir ? str_replace($page_dir, '', $script_path) : $script_path;
     }
     $script_path .= substr($script_path, -1, 1) == '/' ? '' : '/';
     $root_script_path .= substr($root_script_path, -1, 1) == '/' ? '' : '/';
     $page_array += array('page_name' => $page_name, 'page_dir' => $page_dir, 'query_string' => $query_string, 'script_path' => str_replace(' ', '%20', htmlspecialchars($script_path)), 'root_script_path' => str_replace(' ', '%20', htmlspecialchars($root_script_path)), 'page' => $page, 'forum' => isset($_REQUEST['f']) && $_REQUEST['f'] > 0 ? (int) $_REQUEST['f'] : 0);
     return $page_array;
 }
开发者ID:esacinc,项目名称:forum-sitplatform-org-website,代码行数:65,代码来源:session.php

示例5: _aGetCurrentMenu

 private function _aGetCurrentMenu()
 {
     $cur_uri = KOperation_Func::sGetCurUri();
     $cur_uri_params = KOperation_Func::aGetCurUriParams();
     $has_params = false;
     $cur_menu = array();
     if ($cur_uri) {
         $menu_api = new KOperation_Menu_Api();
         $cur_menus = $menu_api->aGetByUri($cur_uri);
         if ($cur_menus) {
             foreach ($cur_menus as $menu) {
                 $tmp_menu_params = KOperation_Func::aGetUriParams($menu['url']);
                 if ($cur_uri_params === $tmp_menu_params || count(array_intersect_assoc($tmp_menu_params, $cur_uri_params)) > 0) {
                     $cur_menu = $menu;
                     $has_params = true;
                     break;
                 }
             }
         }
     }
     if (!$has_params && !empty($cur_menus)) {
         $cur_menu = array_shift($cur_menus);
     }
     return $cur_menu;
 }
开发者ID:firaga,项目名称:operation,代码行数:25,代码来源:App.php

示例6: getTypes

 public static function getTypes(array $filter = null)
 {
     if (!($types =& static::$types)) {
         static::getTypesInternal();
     }
     if (!static::$ready) {
         static::$ready = true;
         uasort($types, function ($a, $b) {
             $a = $a['SORT'];
             $b = $b['SORT'];
             return $a < $b ? -1 : ($a > $b ? 1 : 0);
         });
         if (static::$checkModule) {
             $modules = Config::getModules();
             foreach ($types as &$type) {
                 $module = $modules[$type['MODULE']];
                 $type['ACTIVE'] = $module && $module['ACTIVE'];
             }
             unset($type);
         }
     }
     if ($filter) {
         $count = count($filter);
         return array_filter($types, function (array $type) use($count, $filter) {
             return $count == count(array_intersect_assoc($filter, $type));
         });
     } else {
         return $types;
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:30,代码来源:typemanager.php

示例7: bulk_actions

 /**
  * Display the bulk actions dropdown.
  *
  * @since 3.1.0
  * @access public
  */
 function bulk_actions()
 {
     $screen = get_current_screen();
     if (is_null($this->_actions)) {
         $no_new_actions = $this->_actions = $this->get_bulk_actions();
         // This filter can currently only be used to remove actions.
         //$this->_actions = apply_filters( 'bulk_actions-cred' . $screen->id, $this->_actions );
         $this->_actions = array_intersect_assoc($this->_actions, $no_new_actions);
         $two = '';
     } else {
         $two = '2';
     }
     if (empty($this->_actions)) {
         return;
     }
     echo "<select name='action{$two}'>\n";
     echo "<option value='-1' selected='selected'>" . __('Bulk Actions', 'wp-cred') . "</option>\n";
     foreach ($this->_actions as $name => $title) {
         $class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
         echo "\t<option value='{$name}'{$class}>{$title}</option>\n";
     }
     echo "</select>\n";
     submit_button(__('Apply', 'wp-cred'), 'button-secondary action', false, false, array('id' => "doaction{$two}"));
     echo "\n";
     echo "<a style='margin-left:15px' class='button cred-export-all' href='" . cred_route('/Forms/exportAll?all&_wpnonce=' . wp_create_nonce('cred-export-all')) . "' target='_blank' title='" . __('Export All Forms', 'wp-cred') . "'>" . __('Export All Forms', 'wp-cred') . "</a>";
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:32,代码来源:Forms_List_Table.php

示例8: updateAddresses

 /**
  * Adds phone numbers from Order to shipping and billing address records.
  *
  * @param $order
  */
 protected function updateAddresses($order)
 {
     $data = $order->toMap();
     // this is for matching existing address, we don't match on phone numbers though
     $shippingAddress = Address_Shipping::create(array('MemberID' => $this->owner->Member()->ID, 'FirstName' => $data['ShippingFirstName'], 'Surname' => $data['ShippingSurname'], 'Company' => $data['ShippingCompany'], 'Address' => $data['ShippingAddress'], 'AddressLine2' => $data['ShippingAddressLine2'], 'City' => $data['ShippingCity'], 'PostalCode' => $data['ShippingPostalCode'], 'State' => $data['ShippingState'], 'CountryName' => $data['ShippingCountryName'], 'CountryCode' => $data['ShippingCountryCode'], 'RegionName' => isset($data['ShippingRegionName']) ? $data['ShippingRegionName'] : null, 'RegionCode' => isset($data['ShippingRegionCode']) ? $data['ShippingRegionCode'] : null));
     $newShipping = array_filter($shippingAddress->toMap());
     $billingAddress = Address_Billing::create(array('MemberID' => $this->owner->Member()->ID, 'FirstName' => $data['BillingFirstName'], 'Surname' => $data['BillingSurname'], 'Company' => $data['BillingCompany'], 'Address' => $data['BillingAddress'], 'AddressLine2' => $data['BillingAddressLine2'], 'City' => $data['BillingCity'], 'PostalCode' => $data['BillingPostalCode'], 'State' => $data['BillingState'], 'CountryName' => $data['BillingCountryName'], 'CountryCode' => $data['BillingCountryCode'], 'RegionName' => isset($data['BillingRegionName']) ? $data['ShippingRegionName'] : null, 'RegionCode' => isset($data['BillingRegionCode']) ? $data['ShippingRegionCode'] : null));
     $newBilling = array_filter($billingAddress->toMap());
     foreach ($this->owner->Member()->ShippingAddresses() as $address) {
         $existing = array_filter($address->toMap());
         $result = array_intersect_assoc($existing, $newShipping);
         //If no difference, then match is found
         $diff = array_diff_assoc($newShipping, $result);
         $match = empty($diff);
         if ($match) {
             $address->StreakPhone = $order->ShippingStreakPhone;
             $address->StreakMobile = $order->ShippingStreakMobile;
             $address->write();
         }
     }
     foreach ($this->owner->Member()->BillingAddresses() as $address) {
         $existing = array_filter($address->toMap());
         $result = array_intersect_assoc($existing, $newBilling);
         $diff = array_diff_assoc($newBilling, $result);
         $match = empty($diff);
         if ($match) {
             $address->StreakPhone = $order->BillingStreakPhone;
             $address->StreakMobile = $order->BillingStreakMobile;
             $address->write();
         }
     }
 }
开发者ID:swipestreak,项目名称:addresses,代码行数:37,代码来源:Order.php

示例9: findByTerms

 public function findByTerms($queryString)
 {
     $terms = explode(" ", trim(preg_replace("/[ ]+/", " ", $queryString)));
     $results = null;
     foreach ($terms as $term) {
         if (strlen($term) < 2) {
             continue;
         }
         $q = $this->createQueryBuilder();
         $q->field('cloture')->equals(false);
         $q->field('numeroFacture')->notEqual(null);
         if (preg_match('/^[0-9]+\\.[0-9]+$/', $term)) {
             $nbInf = $term - 0.0001;
             $nbSup = $term + 0.0001;
             $q->addOr($q->expr()->field('montantTTC')->lt($nbSup)->gt($nbInf))->addOr($q->expr()->field('montantAPayer')->lt($nbSup)->gt($nbInf));
         } else {
             $q->addOr($q->expr()->field('destinataire.nom')->equals(new \MongoRegex('/.*' . RechercheTool::getCorrespondances($term) . '.*/i')))->addOr($q->expr()->field('numeroFacture')->equals(new \MongoRegex('/.*' . $term . '.*/i')));
         }
         $factures = $q->limit(1000)->getQuery()->execute();
         $currentResults = array();
         foreach ($factures as $facture) {
             $currentResults[$facture->getId()] = $facture->__toString();
         }
         if (!is_null($results)) {
             $results = array_intersect_assoc($results, $currentResults);
         } else {
             $results = $currentResults;
         }
     }
     return is_null($results) ? array() : $results;
 }
开发者ID:24eme,项目名称:aurouze,代码行数:31,代码来源:FactureRepository.php

示例10: findByTerms

 public function findByTerms($queryString, $withNonActif = false, $limit = 1000, $mixWith = false)
 {
     $terms = explode(" ", trim(preg_replace("/[ ]+/", " ", $queryString)));
     $results = null;
     foreach ($terms as $term) {
         if (strlen($term) < 2) {
             continue;
         }
         $q = $this->createQueryBuilder();
         $q->addOr($q->expr()->field('identifiant')->equals(new \MongoRegex('/.*' . $term . '.*/i')))->addOr($q->expr()->field('raisonSociale')->equals(new \MongoRegex('/.*' . RechercheTool::getCorrespondances($term) . '.*/i')))->addOr($q->expr()->field('adresse.adresse')->equals(new \MongoRegex('/.*' . RechercheTool::getCorrespondances($term) . '.*/i')))->addOr($q->expr()->field('adresse.codePostal')->equals(new \MongoRegex('/.*' . $term . '.*/i')))->addOr($q->expr()->field('adresse.commune')->equals(new \MongoRegex('/.*' . RechercheTool::getCorrespondances($term) . '.*/i')));
         if (!$withNonActif) {
             $q->field('actif')->equals(true);
         }
         $societes = $q->limit($limit)->getQuery()->execute();
         $currentResults = array();
         foreach ($societes as $societe) {
             if ($mixWith) {
                 $currentResults[$societe->getId()] = array("doc" => $societe, "score" => "1", "instance" => "Societe");
             } else {
                 $currentResults[$societe->getId()] = $societe->getIntitule();
             }
         }
         if (!is_null($results)) {
             $results = array_intersect_assoc($results, $currentResults);
         } else {
             $results = $currentResults;
         }
     }
     return is_null($results) ? array() : $results;
 }
开发者ID:24eme,项目名称:aurouze,代码行数:30,代码来源:SocieteRepository.php

示例11: isActive

 public function isActive($recursive = false)
 {
     if ($this->request->attributes->get('_route') == $this->route) {
         return count(array_intersect_assoc($this->params, $this->request->query->all())) >= count($this->params);
     }
     return false;
 }
开发者ID:RomanShumkov,项目名称:ZendNavigationBundle,代码行数:7,代码来源:RouterPage.php

示例12: testPostFromForm

 /**
  * Test a very simple RESTful POST request.
  *
  * @group controller
  */
 public function testPostFromForm()
 {
     $bodyRaw = ['message' => 'mock me do you mocker?'];
     $this->mockEnvironment(['PATH_INFO' => '/', 'REQUEST_METHOD' => 'POST', 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', 'slim.input' => 'target=mocker']);
     $response = $this->tacit->invoke();
     $this->assertEquals(array_intersect_assoc($bodyRaw, json_decode($response->getBody(), true)), $bodyRaw);
 }
开发者ID:vgrish,项目名称:tacit,代码行数:12,代码来源:RestfulControllerTest.php

示例13: testSetGetParams

 public function testSetGetParams()
 {
     $params = array('foo' => 'bar', 'boo' => 'bah', 'fee' => 'fi');
     $this->_request->setParams($params);
     $received = $this->_request->getParams();
     $this->assertSame($params, array_intersect_assoc($params, $received));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:7,代码来源:HttpTest.php

示例14: updateCartProductPreHook

 function updateCartProductPreHook(&$params, &$reference)
 {
     error_log("updateCartPostHook - begin");
     $shopping_cart_item = $params['shopping_cart_item'];
     $cart_product =& $params['cart']['products'][$shopping_cart_item];
     $product_id = $cart_product['products_id'];
     $attributes = $cart_product['attributes'];
     foreach ($attributes as $attr) {
         $attribute_id = $attr['products_attributes_id'];
         $qry_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('va.variant_id', 'tx_msvariants_domain_model_variantsattributes va', 'va.product_id=' . $product_id . ' and va.attribute_id=' . $attribute_id);
         $ids = array();
         while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_res)) != false) {
             $ids[$row['variant_id']] = '';
         }
         if (!isset($variant_id)) {
             $variant_id = $ids;
         } else {
             $variant_id = array_intersect_assoc($variant_id, $ids);
         }
     }
     // Variant found
     if (count($variant_id) == 1) {
         $cart_product['variant_id'] = array_keys($variant_id)[0];
     } else {
     }
     error_log("updateCartPostHook - end");
 }
开发者ID:piramidex,项目名称:msvariants,代码行数:27,代码来源:class.tx_msvariants_updatecartproductprehook.php

示例15: test_basic

 public function test_basic()
 {
     $g = new GroongaServer(array('groonga' => $this->bin));
     $g->run();
     $args = json_decode(file_get_contents($this->out), true);
     $expect = array('db' => $g->getDb(), '-d' => true, '--port' => (string) $g->getPort(), '--protocol' => 'http', '--log-path' => $g->getLogFile(), '-n' => true);
     $this->assertSame($expect, array_intersect_assoc($expect, $args));
 }
开发者ID:do-aki,项目名称:php-test-groonga_server,代码行数:8,代码来源:OptionsTest.php


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