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


PHP array_flip函数代码示例

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


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

示例1: __construct

 /**
  * @param modX $modx
  * @param array $config
  */
 public function __construct(modX &$modx, $config = array())
 {
     $this->modx =& $modx;
     $config = array_merge(array('firstClass' => 'first', 'lastClass' => 'last', 'hereClass' => 'active', 'parentClass' => '', 'rowClass' => '', 'outerClass' => '', 'innerClass' => '', 'levelClass' => '', 'selfClass' => '', 'webLinkClass' => '', 'limit' => 0, 'hereId' => 0), $config, array('return' => 'data'));
     if (empty($config['tplInner']) && !empty($config['tplOuter'])) {
         $config['tplInner'] = $config['tplOuter'];
     }
     if (empty($config['hereId']) && !empty($modx->resource)) {
         $config['hereId'] = $modx->resource->id;
     }
     $fqn = $modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true);
     if ($pdoClass = $modx->loadClass($fqn, '', false, true)) {
         $this->pdoTools = new $pdoClass($modx, $config);
     } elseif ($pdoClass = $modx->loadClass($fqn, MODX_CORE_PATH . 'components/pdotools/model/', false, true)) {
         $this->pdoTools = new $pdoClass($modx, $config);
     } else {
         $this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not load pdoFetch from "MODX_CORE_PATH/components/pdotools/model/".');
         return false;
     }
     if ($config['hereId'] && ($currentResource = $this->pdoTools->getObject('modResource', $config['hereId']))) {
         $tmp = $modx->getParentIds($currentResource['id'], 100, array('context' => $currentResource['context_key']));
         $tmp[] = $config['hereId'];
         $this->parentTree = array_flip($tmp);
     }
     $modx->lexicon->load('pdotools:pdomenu');
     return true;
 }
开发者ID:bendasvadim,项目名称:pdoTools,代码行数:31,代码来源:pdomenu.class.php

示例2: validatePartial

 /**
  * Validates a partial array. Some data may be missing from the given $array, then it will be taken from the
  * full array.
  *
  * Since the array can be incomplete, this method does not validate required parameters.
  *
  * @param array $array
  * @param array $fullArray
  *
  * @return bool
  */
 public function validatePartial(array $array, array $fullArray)
 {
     $unvalidatedFields = array_flip(array_keys($array));
     // field validators
     foreach ($this->validators as $field => $validator) {
         unset($unvalidatedFields[$field]);
         // if the value is present
         if (isset($array[$field])) {
             // validate it if a validator is given, skip it otherwise
             if ($validator && !$validator->validate($array[$field])) {
                 $this->setError($validator->getError());
                 return false;
             }
         }
     }
     // check if any unsupported fields remain
     if ($unvalidatedFields) {
         reset($unvalidatedFields);
         $field = key($unvalidatedFields);
         $this->error($this->messageUnsupported, $field);
         return false;
     }
     // post validators
     foreach ($this->postValidators as $validator) {
         if (!$validator->validatePartial($array, $fullArray)) {
             $this->setError($validator->getError());
             return false;
         }
     }
     return true;
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:42,代码来源:CPartialSchemaValidator.php

示例3: widgetsHandler

 public static function widgetsHandler($type, $disable = '')
 {
     $wtype = 'widgets_' . $type;
     $GLOBALS['core']->blog->settings->addNameSpace('widgets');
     $widgets = $GLOBALS['core']->blog->settings->widgets->{$wtype};
     if (!$widgets) {
         // If widgets value is empty, get defaults
         $widgets = self::defaultWidgets($type);
     } else {
         // Otherwise, load widgets
         $widgets = dcWidgets::load($widgets);
     }
     if ($widgets->isEmpty()) {
         // Widgets are empty, don't show anything
         return;
     }
     $disable = preg_split('/\\s*,\\s*/', $disable, -1, PREG_SPLIT_NO_EMPTY);
     $disable = array_flip($disable);
     foreach ($widgets->elements() as $k => $w) {
         if (isset($disable[$w->id()])) {
             continue;
         }
         echo $w->call($k);
     }
 }
开发者ID:nikrou,项目名称:dotclear,代码行数:25,代码来源:_public.php

示例4: getNativeType

 /**
  * This method will return a native type that corresponds to the specified
  * Creole (JDBC-like) type.  Remember that this is really only for "hint" purposes
  * as SQLite is typeless.
  * 
  * If there is more than one matching native type, then the LAST defined 
  * native type will be returned.
  * 
  * @param int $creoleType
  * @return string Native type string.
  */
 public static function getNativeType($creoleType)
 {
     if (self::$reverseMap === null) {
         self::$reverseMap = array_flip(self::$typeMap);
     }
     return @self::$reverseMap[$creoleType];
 }
开发者ID:rodrigoprestesmachado,项目名称:whiteboard,代码行数:18,代码来源:SQLiteTypes.php

示例5: initialize

 public function initialize($content = array(), $identifier = '')
 {
     // check for template
     if (isset($content['template'])) {
         $this->_template = $content['template'];
         unset($content['template']);
     }
     if (isset($identifier)) {
         $this->_identifier = $identifier;
     }
     if (count($content)) {
         $renderItems = array();
         foreach ($content as $key => $item) {
             if (is_array($item)) {
                 $usedItem = array_intersect_key($item, array_flip($this->_allowAttributes));
                 $usedItem['active'] = false;
                 // if language, than replace the url
                 if ($this->_page->config['use_language']) {
                     $usedItem['url'] = $this->_page->currentLanguage . "/" . $usedItem['url'];
                 }
                 // check active
                 if ($usedItem['url'] == $this->_page->uri) {
                     $usedItem['active'] = true;
                 }
                 $usedItem['url'] = $this->_page->config['url'] . $usedItem['url'];
                 $renderItems[] = $usedItem;
             } else {
                 echo "Menu Item must have title and url, please provide!";
             }
         }
         $this->_renderItems = $renderItems;
     }
 }
开发者ID:volkerfricke,项目名称:filedr-cms,代码行数:33,代码来源:menu.php

示例6: fillableFromArray

 /**
  * Get the fillable attributes of a given array.
  *
  * @param  array $attributes
  *
  * @return array
  */
 protected function fillableFromArray(array $attributes)
 {
     if (count($this->getFillable()) > 0 && !static::$unguarded) {
         return array_intersect_key($attributes, array_flip($this->getFillable()));
     }
     return $attributes;
 }
开发者ID:alpineio,项目名称:atlas,代码行数:14,代码来源:AttributeStorage.php

示例7: handle

 /**
  * Generate query expression for a Criterion this handler accepts
  *
  * accept() must be called before calling this method.
  *
  * @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  * @param array $fieldFilters
  *
  * @return \eZ\Publish\Core\Persistence\Database\Expression
  */
 public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $fieldFilters)
 {
     $languages = array_flip($criterion->value);
     /** @var $criterion \eZ\Publish\API\Repository\Values\Content\Query\Criterion\LanguageCode */
     $languages['always-available'] = $criterion->matchAlwaysAvailable;
     return $query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn('language_mask', 'ezcontentobject'), $this->maskGenerator->generateLanguageMask($languages)), 0);
 }
开发者ID:nlescure,项目名称:ezpublish-kernel,代码行数:19,代码来源:LanguageCode.php

示例8: checkIndividually

function checkIndividually()
{
    #----------------------------------------------------------------------
    global $competitionCondition, $chosenWhich;
    echo "<hr /><p>Checking <b>" . $chosenWhich . " individual results</b>... (wait for the result message box at the end)</p>\n";
    #--- Get all results (id, values, format, round).
    $dbResult = mysql_query("\n    SELECT\n      result.id, formatId, roundId, personId, competitionId, eventId, result.countryId,\n      value1, value2, value3, value4, value5, best, average\n    FROM Results result, Competitions competition\n    WHERE competition.id = competitionId\n      {$competitionCondition}\n    ORDER BY formatId, competitionId, eventId, roundId, result.id\n  ") or die("<p>Unable to perform database query.<br/>\n(" . mysql_error() . ")</p>\n");
    #--- Build id sets
    $countryIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Countries")));
    $competitionIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Competitions")));
    $eventIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Events")));
    $formatIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Formats")));
    $roundIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Rounds")));
    #--- Process the results.
    $badIds = array();
    echo "<pre>\n";
    while ($result = mysql_fetch_array($dbResult)) {
        if ($error = checkResult($result, $countryIdSet, $competitionIdSet, $eventIdSet, $formatIdSet, $roundIdSet)) {
            extract($result);
            echo "Error: {$error}\nid:{$id} format:{$formatId} round:{$roundId}";
            echo " ({$value1},{$value2},{$value3},{$value4},{$value5}) best+average({$best},{$average})\n";
            echo "{$personId}   {$countryId}   {$competitionId}   {$eventId}\n\n";
            $badIds[] = $id;
        }
    }
    echo "</pre>";
    #--- Free the results.
    mysql_free_result($dbResult);
    #--- Tell the result.
    noticeBox2(!count($badIds), "All checked results pass our checking procedure successfully.<br />" . wcaDate(), count($badIds) . " errors found. Get them with this:<br /><br />SELECT * FROM Results WHERE id in (" . implode(', ', $badIds) . ")");
}
开发者ID:Baiqiang,项目名称:worldcubeassociation.org,代码行数:31,代码来源:check_results.php

示例9: writeUntouched

 public function writeUntouched()
 {
     $touched = array_flip($this->getTouchedFiles());
     $untouched = array();
     $this->getUntouchedFiles($untouched, $touched, '.', '.');
     $this->includeUntouchedFiles($untouched);
 }
开发者ID:ilune,项目名称:simpletest,代码行数:7,代码来源:coverage.php

示例10: __construct

 /** The constructor
  * @access public
  * @param array $options
  * @return void
  */
 public function __construct(array $options = null)
 {
     $finds = new Findspots();
     $schema = $finds->info();
     $fields = array_flip($schema['cols']);
     $remove = array('updated', 'created', 'updatedBy', 'createdBy', 'institution', 'findID', 'address', 'fourFigure', 'gridlen', 'postcode', 'easting', 'northing', 'declong', 'declat', 'fourFigureLat', 'fourFigureLon', 'woeid', 'geonamesID', 'osmNode', 'elevation', 'geohash', 'country', 'map25k', 'map10k', 'soiltype', 'smrref', 'otherref', 'id', 'accuracy', 'secuid', 'old_occupierid', 'occupier', 'old_findspotid', 'date');
     foreach ($remove as $rem) {
         unset($fields[$rem]);
     }
     $labels = array('gridrefcert' => 'Grid reference certainty', 'gridref' => 'Grid reference', 'knownas' => 'Known as', 'disccircum' => 'Discovery circumstances', 'gridrefsrc' => 'Grid reference source', 'landusevalue' => 'Land use value', 'landusecode' => 'Land use code', 'depthdiscovery' => 'Depth of discovery', 'Highsensitivity' => 'High sensitivity');
     parent::__construct($options);
     $this->setName('configureFindSpotCopy');
     $elements = array();
     foreach (array_keys($fields) as $field) {
         $label = $field;
         $field = new Zend_Form_Element_Checkbox($field);
         if (array_key_exists($label, $labels)) {
             $clean = ucfirst($labels[$label]);
         } else {
             $clean = ucfirst($label);
         }
         $field->setLabel($clean)->setRequired(false)->addValidator('NotEmpty', 'boolean');
         $elements[] = $field;
         $this->addElement($field);
     }
     $this->addDisplayGroup($elements, 'details');
     //Submit button
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Submit find spot configuration');
     $this->addElement($submit);
     $this->details->setLegend('Choose fields: ');
     parent::init();
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:38,代码来源:ConfigureFindSpotCopyForm.php

示例11: render

 /**
  * Return the views output
  *
  *  @return string 	The output of the view
  */
 public function render()
 {
     $rows = '';
     $columns = array();
     $rowset = $this->getModel()->getRowset();
     // Get the columns
     foreach ($rowset as $row) {
         $data = $row->toArray();
         $columns = array_merge($columns + array_flip(array_keys($data)));
     }
     // Empty the column values
     foreach ($columns as $key => $value) {
         $columns[$key] = '';
     }
     //Create the rows
     foreach ($rowset as $row) {
         $data = $row->toArray();
         $data = array_merge($columns, $data);
         $rows .= $this->_arrayToString(array_values($data)) . $this->eol;
     }
     // Create the header
     $header = $this->_arrayToString(array_keys($columns)) . $this->eol;
     // Set the content
     $this->setContent($header . $rows);
     return parent::render();
 }
开发者ID:janssit,项目名称:nickys.janss.be,代码行数:31,代码来源:csv.php

示例12: getMaterialsCountByStructures

 /**
  * Get materials count grouped by structure selectors
  * @param mixed $selectors Collection of structures selectors to group materials
  * @param string $selector Selector to find structures, [Url] is used by default
  * @param callable $handler External handler
  *
  * @return \integer[] Collection where key is structure selector and value is materials count
  */
 public static function getMaterialsCountByStructures($selectors, $selector = 'Url', $handler = null)
 {
     // If not array is passed
     if (!is_array($selectors)) {
         // convert it to array
         $selectors = array($selectors);
     }
     /** @var integer[] $results Collection of materials count grouped by selectors as array keys */
     $results = array_flip($selectors);
     /** @var Navigation[] $countData */
     $countData = null;
     $query = dbQuery('structure')->cond($selector, $selectors)->add_field('Count(material.materialid)', '__Count', false)->join('structurematerial')->join('material')->cond('material_Active', 1)->cond('material_Published', 1)->cond('material_Draft', 0)->group_by('structureid');
     if (is_callable($handler)) {
         call_user_func($handler, array(&$query));
     }
     // Perform db request to get materials count by passed structure selectors
     if ($query->exec($countData)) {
         foreach ($countData as $result) {
             // Check if we have this structure in results array
             if (isset($results[$result->Url])) {
                 // Store materials count
                 $results[$result->Url . 'Count'] = $result->__Count;
             }
         }
     }
     foreach ($selectors as $select) {
         unset($results[$select]);
     }
     return $results;
 }
开发者ID:samsonos,项目名称:cms_api,代码行数:38,代码来源:CMS.php

示例13: dump_export_data

 public function dump_export_data()
 {
     if ($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS && $this->exporter->get('artefactexportmode') == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS) {
         // Dont' care about profile information in this case
         return;
     }
     $smarty = $this->exporter->get_smarty('../../', 'internal');
     $smarty->assign('page_heading', get_string('profilepage', 'artefact.internal'));
     // Profile page
     $profileviewid = $this->exporter->get('user')->get_profile_view()->get('id');
     foreach ($this->exporter->get('views') as $viewid => $view) {
         if ($profileviewid == $viewid) {
             $smarty->assign('breadcrumbs', array(array('text' => 'Profile page', 'path' => 'profilepage.html')));
             $view = $this->exporter->get('user')->get_profile_view();
             $outputfilter = new HtmlExportOutputFilter('../../');
             $smarty->assign('view', $outputfilter->filter($view->build_columns()));
             $content = $smarty->fetch('export:html/internal:profilepage.tpl');
             if (!file_put_contents($this->fileroot . 'profilepage.html', $content)) {
                 throw new SystemException("Unable to write profile page");
             }
             $this->profileviewexported = true;
             break;
         }
     }
     // Generic profile information
     $smarty->assign('page_heading', get_string('profileinformation', 'artefact.internal'));
     $smarty->assign('breadcrumbs', array(array('text' => 'Profile information', 'path' => 'index.html')));
     // Organise profile information by sections, ordered how it's ordered
     // on the 'edit profile' page
     $sections = array('aboutme' => array(), 'contact' => array(), 'messaging' => array(), 'general' => array());
     $elementlist = call_static_method('ArtefactTypeProfile', 'get_all_fields');
     $elementlistlookup = array_flip(array_keys($elementlist));
     $profilefields = get_column_sql('SELECT id FROM {artefact} WHERE owner=? AND artefacttype IN (' . join(",", array_map(create_function('$a', 'return db_quote($a);'), array_keys($elementlist))) . ")", array($this->exporter->get('user')->get('id')));
     foreach ($profilefields as $id) {
         $artefact = artefact_instance_from_id($id);
         $rendered = $artefact->render_self(array('link' => true));
         if ($artefact->get('artefacttype') == 'introduction') {
             $outputfilter = new HtmlExportOutputFilter('../../');
             $rendered['html'] = $outputfilter->filter($rendered['html']);
         }
         $sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = array('html' => $rendered['html'], 'weight' => $elementlistlookup[$artefact->get('artefacttype')]);
     }
     // Sort the data and then drop the weighting information
     foreach ($sections as &$section) {
         uasort($section, create_function('$a, $b', 'return $a["weight"] > $b["weight"];'));
         foreach ($section as &$data) {
             $data = $data['html'];
         }
     }
     $smarty->assign('sections', $sections);
     $iconid = $this->exporter->get('user')->get('profileicon');
     if ($iconid) {
         $icon = artefact_instance_from_id($iconid);
         $smarty->assign('icon', '<img src="../../static/profileicons/200px-' . PluginExportHtml::sanitise_path($icon->get('title')) . '" alt="Profile Icon">');
     }
     $content = $smarty->fetch('export:html/internal:index.tpl');
     if (!file_put_contents($this->fileroot . 'index.html', $content)) {
         throw new SystemException("Unable to write profile information page");
     }
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:60,代码来源:lib.php

示例14: loadCharset

 function loadCharset($charset)
 {
     $charset = preg_replace(array('/^WINDOWS-*125([0-8])$/', '/^CP-/'), array('CP125\\1', 'CP'), $charset);
     if (isset($aliases[$charset])) {
         $charset = $aliases[$charset];
     }
     $this->charset = $charset;
     if (empty($this->ascMap[$charset])) {
         $file = UTF8_MAP_DIR . '/' . $charset . '.map';
         if (!is_file($file)) {
             $this->onError(ERR_OPEN_MAP_FILE, "Failed to open map file for {$charset}");
             return;
         }
         $lines = file_get_contents($file);
         $lines = preg_replace("/#.*\$/m", "", $lines);
         $lines = preg_replace("/\n\n/", "", $lines);
         $lines = explode("\n", $lines);
         foreach ($lines as $line) {
             $parts = explode('0x', $line);
             if (count($parts) == 3) {
                 $asc = hexdec(substr($parts[1], 0, 2));
                 $utf = hexdec(substr($parts[2], 0, 4));
                 $this->ascMap[$charset][$asc] = $utf;
             }
         }
         $this->utfMap = array_flip($this->ascMap[$charset]);
     }
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:28,代码来源:utf8.class.php

示例15: run

 public function run()
 {
     $app = $this->xtr->getApplication();
     /** @var $matcher RedirectableUrlMatcher */
     $context = $app['request_context'];
     $matched = false;
     $path = $this->xtr->getRequest()->getPathInfo();
     $lastException = null;
     // matching fallback route groups:
     foreach ($this->xtr['routes'] as $fallback => $routes) {
         $routes = RouteCollection::FromArray($routes)->flat();
         $matcher = new RedirectableUrlMatcher($routes->toSilexCollection(), $context);
         try {
             $matcher->match($path);
             $matched = $fallback;
             break;
         } catch (ResourceNotFoundException $e) {
             // not found: silent continue
             $lastException = $e;
         }
     }
     if ($matched === false) {
         throw $lastException;
     }
     // configuring distinct service:
     $allow = [$matched];
     $fallbacks = array_flip(array_keys($this->xtr['routes']));
     unset($fallbacks[$matched]);
     $deny = array_keys($fallbacks);
     $this->xtr['@distinct.settings'] = ['allow' => $allow, 'deny' => $deny];
 }
开发者ID:Webapper,项目名称:silex-xtr,代码行数:31,代码来源:Fallbacks.php


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