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


PHP array_unshift函数代码示例

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


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

示例1: entry

function entry(&$argv)
{
    if (is_file($argv[0])) {
        if (0 === substr_compare($argv[0], '.class.php', -10)) {
            $uri = realpath($argv[0]);
            if (null === ($cl = \lang\ClassLoader::getDefault()->findUri($uri))) {
                throw new \Exception('Cannot load ' . $uri . ' - not in class path');
            }
            return $cl->loadUri($uri)->literal();
        } else {
            if (0 === substr_compare($argv[0], '.xar', -4)) {
                $cl = \lang\ClassLoader::registerPath($argv[0]);
                if (!$cl->providesResource('META-INF/manifest.ini')) {
                    throw new \Exception($cl->toString() . ' does not provide a manifest');
                }
                $manifest = parse_ini_string($cl->getResource('META-INF/manifest.ini'));
                return strtr($manifest['main-class'], '.', '\\');
            } else {
                array_unshift($argv, 'eval');
                return 'xp\\runtime\\Evaluate';
            }
        }
    } else {
        return strtr($argv[0], '.', '\\');
    }
}
开发者ID:xp-runners,项目名称:main,代码行数:26,代码来源:entry.php

示例2: getInput

 protected function getInput()
 {
     $html = '';
     $db = JFactory::getDbo();
     $options = JUDownloadHelper::getFieldGroupOptions();
     if ($this->element['usenone'] == 'true') {
         array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
     }
     if ($this->element['useinherit'] == 'true') {
         $appendInherit = "";
         if ($this->form->getValue("id")) {
             $appendInherit = " ( " . JText::_('COM_JUDOWNLOAD_NONE') . " )";
             if ($this->form->getValue("id") > 0) {
                 $catObj = JUDownloadHelper::getCategoryById($this->form->getValue("parent_id"));
                 if ($catObj->fieldgroup_id > 1) {
                     $query = "SELECT name, published FROM #__judownload_fields_groups WHERE id = " . (int) $catObj->fieldgroup_id . " AND id != 1";
                     $db->setQuery($query);
                     $fieldgroup = $db->loadObject();
                     $groupName = $fieldgroup->published != 1 ? "[" . $fieldgroup->name . "]" : $fieldgroup->name;
                     $appendInherit = "( " . $groupName . " )";
                 }
             }
         }
         array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
     } else {
         array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_FIELD_GROUP')));
     }
     $required_class = $this->element['required'] == 'true' ? 'required' : '';
     $attributes = "class=\"inputbox {$required_class}\"";
     $html .= JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
     return $html;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:32,代码来源:fieldgroupforcat.php

示例3: display

 function display($tmpl_file, $app_id = null)
 {
     array_unshift($this->_files, $tmpl_file);
     $this->_vars = $this->pagedata;
     if ($p = strpos($tmpl_file, ':')) {
         $object = kernel::service('tpl_source.' . substr($tmpl_file, 0, $p));
         if ($object) {
             $tmpl_file_path = substr($tmpl_file, $p + 1);
             $last_modified = $object->last_modified($tmpl_file_path);
         }
     } else {
         $tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file);
         $last_modified = filemtime($tmpl_file);
     }
     if (!$last_modified) {
         //无文件
     }
     $compile_id = $this->compile_id($tmpl_file);
     if ($object) {
         $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
     } else {
         $compile_code = $this->_compiler()->compile_file($tmpl_file);
     }
     eval('?>' . $compile_code);
     array_shift($this->_files);
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:26,代码来源:controller.php

示例4: getLanguageList

 /**
  * Get an HTML select list of the available languages.
  *
  * @return	string
  */
 public static function getLanguageList()
 {
     $languages = array();
     $languages = JLanguageHelper::createLanguageList(null, JPATH_ADMINISTRATOR, false, true);
     array_unshift($languages, JHtml::_('select.option', '', JText::_('JDEFAULT')));
     return JHtml::_('select.genericlist', $languages, 'lang', ' class="inputbox"', 'value', 'text', null);
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:12,代码来源:helper.php

示例5: register

 public function register($path, $namespace = 'default')
 {
     if (!isset($this->_paths[$namespace])) {
         $this->_paths[$namespace] = array();
     }
     array_unshift($this->_paths[$namespace], $path);
 }
开发者ID:ConceptHaus,项目名称:huasca,代码行数:7,代码来源:path.php

示例6: fetchElement

 function fetchElement($name, $value, &$node, $control_name)
 {
     jimport('joomla.filesystem.folder');
     // path to images directory
     $path = JPATH_ROOT . DS . $node->attributes('directory');
     $filter = $node->attributes('filter');
     $exclude = $node->attributes('exclude');
     $recursive = $node->attributes('recursive') == 1 ? true : false;
     $folders = JFolder::folders($path, $filter, $recursive);
     $folders = $this->recursive_listdir($path, $node);
     $options = array();
     foreach ($folders as $key => $folder) {
         if ($exclude) {
             if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
                 continue;
             }
         }
         $options[] = JHTML::_('select.option', $key, $folder);
     }
     if (!$node->attributes('hide_none')) {
         array_unshift($options, JHTML::_('select.option', '-1', '- ' . JText::_('Do not use') . ' -'));
     }
     if (!$node->attributes('hide_default')) {
         array_unshift($options, JHTML::_('select.option', '', '- ' . JText::_('Use default') . ' -'));
     }
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $options, $fullName, 'class="inputbox"', 'value', 'text', $value, "params{$name}");
 }
开发者ID:nikshade,项目名称:fabrik21,代码行数:28,代码来源:recursivefolderlist.php

示例7: __construct

 function __construct(&$lines, $level)
 {
     $res = array();
     $body = array();
     while (count($lines)) {
         $line = array_shift($lines);
         // Blank lines just get a carriage return added (for markdown) and otherwise ignored
         if (!trim($line)) {
             $body[] = "\n";
             continue;
         }
         // Get the indent
         preg_match('/^(\\s*)/', $line, $match);
         $indent = $match[1];
         // Check to make sure we're still indented
         if (strlen($indent) <= $level) {
             array_unshift($lines, $line);
             break;
         }
         // Check for tag
         if (preg_match('/^@([^\\s]+)(.*)$/', trim($line), $match)) {
             $tag = $match[1];
             $sub = new RESTDocblockParser($lines, strlen($indent));
             $sub['details'] = trim($match[2]);
             if (!isset($res[$tag])) {
                 $res[$tag] = new RESTDocblockParser_Sequence();
             }
             $res[$tag][] = $sub;
         } else {
             $body[] = substr($line, $level > 0 ? $level : 0);
         }
     }
     $res['body'] = Markdown(implode("", $body));
     $this->res = $res;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-restassured,代码行数:35,代码来源:RESTDocblockParser.php

示例8: action_index

 public function action_index($options = array("max" => 10, "current" => 1, "count" => 5))
 {
     $model = array();
     $pages = array();
     $max_page = $options["max"];
     // Максимальное количество страниц
     $current_page = $options["current"];
     // Текущая страница
     $pages_length = $options["count"];
     // Количество номеров страниц (нечётное число)
     $next_prev_pages = floor($pages_length / 2);
     // Количество доп. страниц
     $pages[] = array("href" => "#", "active" => "active", "num" => $current_page);
     // Создание доп. страниц
     for ($i = 1; $i <= $next_prev_pages; $i++) {
         if ($current_page - $i > 1) {
             array_unshift($pages, array("href" => URL::query(array("page" => $current_page - $i)), "num" => $current_page - $i));
         }
         if ($current_page + $i < $max_page) {
             array_push($pages, array("href" => URL::query(array("page" => $current_page + $i)), "num" => $current_page + $i));
         }
     }
     if ($current_page > 1) {
         $model["min_page"] = array("num" => 1, "href" => URL::query(array("page" => 1)));
         $model["prev_href"] = URL::query(array("page" => $current_page - 1));
     }
     if ($current_page < $max_page) {
         $model["max_page"] = array("num" => $max_page, "href" => URL::query(array("page" => $max_page)));
         $model["next_href"] = URL::query(array("page" => $current_page + 1));
     }
     $model["pages"] = $pages;
     $this->set_template("/widgets/twig_pagination.php", "twig")->render($model)->body();
 }
开发者ID:chernogolov,项目名称:blank,代码行数:33,代码来源:Pagination.php

示例9: filter

 /**
  * Filter
  *
  * @return void
  */
 public function filter()
 {
     /*
      * Variable qui contient la chaine de recherche
      */
     if (is_array($this->terms)) {
         $stringSearch = implode(' ', $this->terms);
     } else {
         $stringSearch = $this->terms;
     }
     /*
      * On divise en mots (séparé par des espace)
      */
     $words = preg_split('`\\s+`', $stringSearch, -1, PREG_SPLIT_NO_EMPTY);
     if (count($words) > 1) {
         array_unshift($words, $stringSearch);
     }
     $words = array_unique($words);
     $conds = [];
     foreach ($words as $index => $word) {
         foreach ($this->columns as $colName) {
             $cond = $this->queryBuilder->expr()->like($colName, ':word_' . ($index + 1));
             $this->queryBuilder->setParameter('word_' . ($index + 1), '%' . $word . '%');
             $conds[] = $cond;
         }
     }
     $this->queryBuilder->andWhere(implode(' OR ', $conds));
 }
开发者ID:solire,项目名称:trieur,代码行数:33,代码来源:Contain.php

示例10: get_progress_bar

 /**
  * Customises the backup progress bar
  *
  * @global moodle_page $PAGE
  * @return array
  */
 public function get_progress_bar()
 {
     global $PAGE;
     $stage = self::STAGE_COMPLETE;
     $currentstage = $this->stage->get_stage();
     $items = array();
     while ($stage > 0) {
         $classes = array('backup_stage');
         if (floor($stage / 2) == $currentstage) {
             $classes[] = 'backup_stage_next';
         } else {
             if ($stage == $currentstage) {
                 $classes[] = 'backup_stage_current';
             } else {
                 if ($stage < $currentstage) {
                     $classes[] = 'backup_stage_complete';
                 }
             }
         }
         $item = array('text' => strlen(decbin($stage * 2)) . '. ' . get_string('importcurrentstage' . $stage, 'backup'), 'class' => join(' ', $classes));
         if ($stage < $currentstage && $currentstage < self::STAGE_COMPLETE && (!self::$skipcurrentstage || $stage * 2 != $currentstage)) {
             $item['link'] = new moodle_url($PAGE->url, $this->stage->get_params() + array('backup' => $this->get_backupid(), 'stage' => $stage));
         }
         array_unshift($items, $item);
         $stage = floor($stage / 2);
     }
     $selectorlink = new moodle_url($PAGE->url, $this->stage->get_params());
     $selectorlink->remove_params('importid');
     array_unshift($items, array('text' => '1. ' . get_string('importcurrentstage0', 'backup'), 'class' => join(' ', $classes), 'link' => $selectorlink));
     return $items;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:37,代码来源:import_extensions.php

示例11: on_start

 public function on_start()
 {
     $this->error = Loader::helper('validation/error');
     if (USER_REGISTRATION_WITH_EMAIL_ADDRESS == true) {
         $this->set('uNameLabel', t('Email Address'));
     } else {
         $this->set('uNameLabel', t('Username'));
     }
     $txt = Loader::helper('text');
     if (strlen($_GET['uName'])) {
         // pre-populate the username if supplied, if its an email address with special characters the email needs to be urlencoded first,
         $this->set("uName", trim($txt->email($_GET['uName'])));
     }
     $languages = array();
     $locales = array();
     if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN')) {
         Loader::library('3rdparty/Zend/Locale');
         Loader::library('3rdparty/Zend/Locale/Data');
         $languages = Localization::getAvailableInterfaceLanguages();
         if (count($languages) > 0) {
             array_unshift($languages, 'en_US');
         }
         $locales = array('' => t('** Default'));
         Zend_Locale_Data::setCache(Cache::getLibrary());
         foreach ($languages as $lang) {
             $loc = new Zend_Locale($lang);
             $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', ACTIVE_LOCALE);
         }
     }
     $this->locales = $locales;
     $this->set('locales', $locales);
     $this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
 }
开发者ID:ricardomccerqueira,项目名称:rcerqueira.portfolio,代码行数:33,代码来源:login.php

示例12: __

 public function __()
 {
     $args = func_get_args();
     $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), 'Mage_GoogleCheckout');
     array_unshift($args, $expr);
     return Mage::app()->getTranslator()->translate($args);
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:7,代码来源:Abstract.php

示例13: hook_menu

 function hook_menu(&$items)
 {
     // Change the item to a tab.
     $this->plugin['menu']['items']['list']['type'] = MENU_LOCAL_TASK;
     $this->plugin['menu']['items']['list']['weight'] = -6;
     $this->plugin['menu']['items']['list']['title'] = 'List defaults';
     // menu local actions are weird.
     $this->plugin['menu']['items']['add']['path'] = 'list/add';
     $this->plugin['menu']['items']['import']['path'] = 'list/import';
     // Edit is being handled elsewhere.
     unset($this->plugin['menu']['items']['edit callback']);
     unset($this->plugin['menu']['items']['access']);
     foreach (panelizer_operations() as $path => $operation) {
         $location = isset($operation['ui path']) ? $operation['ui path'] : $path;
         if (isset($this->plugin['menu']['items'][$location])) {
             unset($this->plugin['menu']['items'][$location]);
         }
     }
     // Change the callbacks for everything.
     foreach ($this->plugin['menu']['items'] as $key => $item) {
         // The item has already been set; continue to next item to avoid shifting
         // items onto the page arguments array more than once.
         if ($this->plugin['menu']['items'][$key]['access callback'] == 'panelizer_has_choice_callback') {
             continue;
         }
         $this->plugin['menu']['items'][$key]['access callback'] = 'panelizer_has_choice_callback';
         $this->plugin['menu']['items'][$key]['access arguments'] = array(3, 4, '');
         $this->plugin['menu']['items'][$key]['page callback'] = 'panelizer_export_ui_switcher_page';
         array_unshift($this->plugin['menu']['items'][$key]['page arguments'], 4);
         array_unshift($this->plugin['menu']['items'][$key]['page arguments'], 3);
     }
     parent::hook_menu($items);
 }
开发者ID:redponey,项目名称:openatrium-7.x-2.51,代码行数:33,代码来源:panelizer_defaults_ui.class.php

示例14: act_plugin_action_links

function act_plugin_action_links($links)
{
    $settings_link = '<a href="admin.php?page=act_admin#act_date">' . __('Settings') . '</a>';
    $uninstall_link = '<a href="admin.php?page=act_admin#act_reset">' . __('Uninstall') . '</a>';
    array_unshift($links, $settings_link, $uninstall_link);
    return $links;
}
开发者ID:sara62,项目名称:wp-activity,代码行数:7,代码来源:wp-act-admin.php

示例15: block

 /**
  * Formats a message as a block of text.
  *
  * @param string|array $messages The message to write in the block
  * @param string|null $type The block type (added in [] on first line)
  * @param string|null $style The style to apply to the whole block
  * @param string $prefix The prefix for the block
  * @param bool $padding Whether to add vertical padding
  */
 public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
 {
     $this->autoPrependBlock();
     $messages = is_array($messages) ? array_values($messages) : array($messages);
     $lines = array();
     // add type
     if (null !== $type) {
         $messages[0] = sprintf('[%s] %s', $type, $messages[0]);
     }
     // wrap and add newlines for each element
     foreach ($messages as $key => $message) {
         $message = OutputFormatter::escape($message);
         $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - Helper::strlen($prefix), PHP_EOL, true)));
         if (count($messages) > 1 && $key < count($messages) - 1) {
             $lines[] = '';
         }
     }
     if ($padding && $this->isDecorated()) {
         array_unshift($lines, '');
         $lines[] = '';
     }
     foreach ($lines as &$line) {
         $line = sprintf('%s%s', $prefix, $line);
         $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
         if ($style) {
             $line = sprintf('<%s>%s</>', $style, $line);
         }
     }
     $this->writeln($lines);
     $this->newLine();
 }
开发者ID:a53ali,项目名称:CakePhP,代码行数:40,代码来源:SymfonyStyle.php


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