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


PHP array_pop函数代码示例

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


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

示例1: vc_dropdown_form_field

/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value));
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $selected = '';
            $option_value_string = (string) $option_value;
            $value_string = (string) $value;
            if ('' !== $value && $option_value_string === $value_string) {
                $selected = ' selected="selected"';
            }
            $option_class = str_replace('#', 'hash-', $option_value);
            $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
开发者ID:severnrescue,项目名称:web,代码行数:42,代码来源:default_params.php

示例2: buttonDropDown

 /**
  * Write a button drop down control.
  *
  * @param array $Links An array of arrays with the following keys:
  *  - Text: The text of the link.
  *  - Url: The url of the link.
  * @param string|array $CssClass The css class of the link. This can be a two-item array where the second element will be added to the buttons.
  * @param string $Label The text of the button.
  * @since 2.1
  */
 function buttonDropDown($Links, $CssClass = 'Button', $Label = false)
 {
     if (!is_array($Links) || count($Links) < 1) {
         return;
     }
     $ButtonClass = '';
     if (is_array($CssClass)) {
         list($CssClass, $ButtonClass) = $CssClass;
     }
     if (count($Links) < 2) {
         $Link = array_pop($Links);
         if (strpos(GetValue('CssClass', $Link, ''), 'Popup') !== false) {
             $CssClass .= ' Popup';
         }
         echo Anchor($Link['Text'], $Link['Url'], GetValue('ButtonCssClass', $Link, $CssClass));
     } else {
         // NavButton or Button?
         $ButtonClass = ConcatSep(' ', $ButtonClass, strpos($CssClass, 'NavButton') !== false ? 'NavButton' : 'Button');
         if (strpos($CssClass, 'Primary') !== false) {
             $ButtonClass .= ' Primary';
         }
         // Strip "Button" or "NavButton" off the group class.
         echo '<div class="ButtonGroup' . str_replace(array('NavButton', 'Button'), array('', ''), $CssClass) . '">';
         //            echo Anchor($Text, $Url, $ButtonClass);
         echo '<ul class="Dropdown MenuItems">';
         foreach ($Links as $Link) {
             echo wrap(Anchor($Link['Text'], $Link['Url'], val('CssClass', $Link, '')), 'li');
         }
         echo '</ul>';
         echo anchor($Label . ' ' . sprite('SpDropdownHandle'), '#', $ButtonClass . ' Handle');
         echo '</div>';
     }
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:43,代码来源:functions.render.php

示例3: run

 public static function run()
 {
     foreach (glob(app_path() . '/Http/Controllers/*.php') as $filename) {
         $file_parts = explode('/', $filename);
         $file = array_pop($file_parts);
         $file = rtrim($file, '.php');
         if ($file == 'Controller') {
             continue;
         }
         $controllerName = 'App\\Http\\Controllers\\' . $file;
         $controller = new $controllerName();
         if (isset($controller->exclude) && $controller->exclude === true) {
             continue;
         }
         $methods = [];
         $reflector = new \ReflectionClass($controller);
         foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $rMethod) {
             // check whether method is explicitly defined in this class
             if ($rMethod->getDeclaringClass()->getName() == $reflector->getName()) {
                 $methods[] = $rMethod->getName();
             }
         }
         \Route::resource(strtolower(str_replace('Controller', '', $file)), $file, ['only' => $methods]);
     }
 }
开发者ID:avnir,项目名称:easyrouting,代码行数:25,代码来源:Easyrouting.php

示例4: doCompile

    /**
     * Methode to compile a Smarty template
     * 
     * @param  $_content template source
     * @return bool true if compiling succeeded, false if it failed
     */
    protected function doCompile($_content)
    {
        /* here is where the compiling takes place. Smarty
       tags in the templates are replaces with PHP code,
       then written to compiled files. */ 
        // init the lexer/parser to compile the template
        $this->lex = new $this->lexer_class($_content, $this);
        $this->parser = new $this->parser_class($this->lex, $this);
        if (isset($this->smarty->_parserdebug)) $this->parser->PrintTrace(); 
        // get tokens from lexer and parse them
        while ($this->lex->yylex() && !$this->abort_and_recompile) {
            if (isset($this->smarty->_parserdebug)) echo "<pre>Line {$this->lex->line} Parsing  {$this->parser->yyTokenName[$this->lex->token]} Token " . htmlentities($this->lex->value) . "</pre>";
            $this->parser->doParse($this->lex->token, $this->lex->value);
        } 

        if ($this->abort_and_recompile) {
            // exit here on abort
            return false;
        } 
        // finish parsing process
        $this->parser->doParse(0, 0); 
        // check for unclosed tags
        if (count($this->_tag_stack) > 0) {
            // get stacked info
            list($_open_tag, $_data) = array_pop($this->_tag_stack);
            $this->trigger_template_error("unclosed {" . $_open_tag . "} tag");
        } 
        // return compiled code
        // return str_replace(array("? >\n<?php","? ><?php"), array('',''), $this->parser->retvalue);
        return $this->parser->retvalue;
    } 
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:37,代码来源:smarty_internal_smartytemplatecompiler.php

示例5: pop

 /**
  * Restore the most recently pushed set of templates.
  *
  * @return void
  */
 public function pop()
 {
     if (empty($this->_configStack)) {
         return;
     }
     list($this->_config, $this->_compiled) = array_pop($this->_configStack);
 }
开发者ID:wepbunny,项目名称:cake2,代码行数:12,代码来源:StringTemplate.php

示例6: getCurrentPattern

 public function getCurrentPattern()
 {
     $patterns = $this->getAttribute('patterns', array(), 'psdf');
     $pattern = array_pop($patterns);
     $this->setAttribute('patterns', $patterns, 'psdf');
     return $pattern;
 }
开发者ID:psdf,项目名称:psdfCorePlugin,代码行数:7,代码来源:psdfUser.class.php

示例7: run

 public function run()
 {
     //TODO: genericise this behaviour
     $cls_name = explode('\\', get_class($this));
     $this->shortName = array_pop($cls_name);
     if (file_exists(dirname(__FILE__) . '/js/' . $this->shortName . '.js')) {
         $this->assetFolder = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/js/');
         Yii::app()->getClientScript()->registerScriptFile($this->assetFolder . '/' . $this->shortName . '.js');
         Yii::app()->getAssetManager()->registerCssFile('css/module.css', 'application.modules.PatientTicketing.assets', 10, \AssetManager::OUTPUT_ALL);
     }
     if ($this->ticket) {
         $this->event_types = $this->ticket->current_queue->getRelatedEventTypes();
         $this->ticket_info = $this->ticket->getInfoData(false);
         $this->current_queue_name = $this->ticket->current_queue->name;
         $this->outcome_options = array();
         $od = $this->ticket->current_queue->getOutcomeData(false);
         foreach ($od as $out) {
             $this->outcome_options[$out['id']] = $out['name'];
         }
         if (count($od) == 1) {
             $this->outcome_queue_id = $od[0]['id'];
         }
     }
     $this->render('TicketMove');
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:25,代码来源:TicketMove.php

示例8: parsePadding

 public function parsePadding($v)
 {
     $padding = explode('|*|', $v);
     $unit = array_pop($padding);
     $padding[] = '';
     return 'padding:' . implode($unit . ' ', $padding) . ';';
 }
开发者ID:vicpril,项目名称:rep_bidqa,代码行数:7,代码来源:style.php

示例9: lang_getfrombrowser

/**
 * determines the langauge settings of the browser, details see here:
 * http://aktuell.de.selfhtml.org/artikel/php/httpsprache/
 */
function lang_getfrombrowser($allowed_languages, $default_language, $lang_variable = null, $strict_mode = true)
{
    // $_SERVER['HTTP_ACCEPT_LANGUAGE'] verwenden, wenn keine Sprachvariable mitgegeben wurde
    if ($lang_variable === null && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        $lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    }
    // wurde irgendwelche Information mitgeschickt?
    if (empty($lang_variable)) {
        // Nein? => Standardsprache zurückgeben
        return $default_language;
    }
    // Den Header auftrennen
    $accepted_languages = preg_split('/,\\s*/', $lang_variable);
    // Die Standardwerte einstellen
    $current_lang = $default_language;
    $current_q = 0;
    // Nun alle mitgegebenen Sprachen abarbeiten
    foreach ($accepted_languages as $accepted_language) {
        // Alle Infos über diese Sprache rausholen
        $res = preg_match('/^([a-z]{1,8}(?:-[a-z]{1,8})*)' . '(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$/i', $accepted_language, $matches);
        // war die Syntax gültig?
        if (!$res) {
            // Nein? Dann ignorieren
            continue;
        }
        // Sprachcode holen und dann sofort in die Einzelteile trennen
        $lang_code = explode('-', $matches[1]);
        // Wurde eine Qualität mitgegeben?
        if (isset($matches[2])) {
            // die Qualität benutzen
            $lang_quality = (double) $matches[2];
        } else {
            // Kompabilitätsmodus: Qualität 1 annehmen
            $lang_quality = 1.0;
        }
        // Bis der Sprachcode leer ist...
        while (count($lang_code)) {
            // mal sehen, ob der Sprachcode angeboten wird
            if (in_array(strtolower(join('-', $lang_code)), $allowed_languages)) {
                // Qualität anschauen
                if ($lang_quality > $current_q) {
                    // diese Sprache verwenden
                    $current_lang = strtolower(join('-', $lang_code));
                    $current_q = $lang_quality;
                    // Hier die innere while-Schleife verlassen
                    break;
                }
            }
            // Wenn wir im strengen Modus sind, die Sprache nicht versuchen zu minimalisieren
            if ($strict_mode) {
                // innere While-Schleife aufbrechen
                break;
            }
            // den rechtesten Teil des Sprachcodes abschneiden
            array_pop($lang_code);
        }
    }
    // die gefundene Sprache zurückgeben
    return $current_lang;
}
开发者ID:adartk,项目名称:phpsqlitecms,代码行数:64,代码来源:language_redirect.php

示例10: tplsadmin_copy_templates_db2db

function tplsadmin_copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
    global $db;
    // get tplfile and tplsource
    $result = $db->query("SELECT tpl_refid,tpl_module,'" . addslashes($tplset_to) . "',tpl_file,tpl_desc,tpl_lastmodified,tpl_lastimported,tpl_type,tpl_source FROM " . $db->prefix("tplfile") . " NATURAL LEFT JOIN " . $db->prefix("tplsource") . " WHERE tpl_tplset='" . addslashes($tplset_from) . "' AND ({$whr_append})");
    while ($row = $db->fetchArray($result)) {
        $tpl_source = array_pop($row);
        $drs = $db->query("SELECT tpl_id FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($tplset_to) . "' AND ({$whr_append}) AND tpl_file='" . addslashes($row['tpl_file']) . "' AND tpl_refid='" . addslashes($row['tpl_refid']) . "'");
        if (!$db->getRowsNum($drs)) {
            // INSERT mode
            $sql = "INSERT INTO " . $db->prefix("tplfile") . " (tpl_refid,tpl_module,tpl_tplset,tpl_file,tpl_desc,tpl_lastmodified,tpl_lastimported,tpl_type) VALUES (";
            foreach ($row as $colval) {
                $sql .= "'" . addslashes($colval) . "',";
            }
            $db->query(substr($sql, 0, -1) . ')');
            $tpl_id = $db->getInsertId();
            $db->query("INSERT INTO " . $db->prefix("tplsource") . " SET tpl_id='{$tpl_id}', tpl_source='" . addslashes($tpl_source) . "'");
            altsys_template_touch($tpl_id);
        } else {
            while (list($tpl_id) = $db->fetchRow($drs)) {
                // UPDATE mode
                $db->query("UPDATE " . $db->prefix("tplfile") . " SET tpl_refid='" . addslashes($row['tpl_refid']) . "',tpl_desc='" . addslashes($row['tpl_desc']) . "',tpl_lastmodified='" . addslashes($row['tpl_lastmodified']) . "',tpl_lastimported='" . addslashes($row['tpl_lastimported']) . "',tpl_type='" . addslashes($row['tpl_type']) . "' WHERE tpl_id='{$tpl_id}'");
                $db->query("UPDATE " . $db->prefix("tplsource") . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='{$tpl_id}'");
                altsys_template_touch($tpl_id);
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:28,代码来源:tpls_functions.php

示例11: su_lang_implode

/**
* Joins strings into a natural-language list.
* Can be internationalized with gettext or the su_lang_implode filter.
* 
* @since 1.1
* 
* @param array $items The strings (or objects with $var child strings) to join.
* @param string|false $var The name of the items' object variables whose values should be imploded into a list.
	If false, the items themselves will be used.
* @param bool $ucwords Whether or not to capitalize the first letter of every word in the list.
* @return string|array The items in a natural-language list.
*/
function su_lang_implode($items, $var = false, $ucwords = false)
{
    if (is_array($items)) {
        if (strlen($var)) {
            $_items = array();
            foreach ($items as $item) {
                $_items[] = $item->{$var};
            }
            $items = $_items;
        }
        if ($ucwords) {
            $items = array_map('ucwords', $items);
        }
        switch (count($items)) {
            case 0:
                $list = '';
                break;
            case 1:
                $list = $items[0];
                break;
            case 2:
                $list = sprintf(__('%s and %s', 'seo-update'), $items[0], $items[1]);
                break;
            default:
                $last = array_pop($items);
                $list = implode(__(', ', 'seo-update'), $items);
                $list = sprintf(__('%s, and %s', 'seo-update'), $list, $last);
                break;
        }
        return apply_filters('su_lang_implode', $list, $items);
    }
    return $items;
}
开发者ID:Kishor900,项目名称:scrapboard,代码行数:45,代码来源:seo-functions.php

示例12: testLogSave

 public function testLogSave()
 {
     $timed = $this->_getMemoryMock();
     $a = array();
     $timed->save($a);
     $this->assertContains('Kolab Format data generation complete. Memory usage:', array_pop($this->logger->log));
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:7,代码来源:MemoryTest.php

示例13: truncate

 /**
  * Truncates a string to the given length.  It will optionally preserve
  * HTML tags if $is_html is set to true.
  *
  * @param   string  $string        the string to truncate
  * @param   int     $limit         the number of characters to truncate too
  * @param   string  $continuation  the string to use to denote it was truncated
  * @param   bool    $is_html       whether the string has HTML
  * @return  string  the truncated string
  */
 public static function truncate($string, $limit, $continuation = '...', $is_html = false)
 {
     $offset = 0;
     $tags = array();
     if ($is_html) {
         // Handle special characters.
         preg_match_all('/&[a-z]+;/i', strip_tags($string), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] >= $limit) {
                 break;
             }
             $limit += static::length($match[0][0]) - 1;
         }
         // Handle all the html tags.
         preg_match_all('/<[^>]+>([^<]*)/', $string, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] - $offset >= $limit) {
                 break;
             }
             $tag = static::sub(strtok($match[0][0], " \t\n\r\v>"), 1);
             if ($tag[0] != '/') {
                 $tags[] = $tag;
             } elseif (end($tags) == static::sub($tag, 1)) {
                 array_pop($tags);
             }
             $offset += $match[1][1] - $match[0][1];
         }
     }
     $new_string = static::sub($string, 0, $limit = min(static::length($string), $limit + $offset));
     $new_string .= static::length($string) > $limit ? $continuation : '';
     $new_string .= count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : '';
     return $new_string;
 }
开发者ID:huglester,项目名称:pyrocms-helpers,代码行数:43,代码来源:Str.php

示例14: create

 /** Creates directory or throws exception on fail
  * @param string $pathname
  * @param int    $mode     Mode in octal
  * @return bool
  */
 public static function create($pathname, $mode = self::MOD_DEFAULT)
 {
     if (strpos($pathname, '/') !== false) {
         $pathname = explode('/', $pathname);
     }
     if (is_array($pathname)) {
         $current_dir = '';
         $create = array();
         do {
             $current_dir = implode('/', $pathname);
             if (is_dir($current_dir)) {
                 break;
             }
             $create[] = array_pop($pathname);
         } while (any($pathname));
         if (any($create)) {
             $create = array_reverse($create);
             $current_dir = implode('/', $pathname);
             foreach ($create as $dir) {
                 $current_dir .= '/' . $dir;
                 if (!is_dir($current_dir)) {
                     if (!($action = @mkdir($current_dir, $mode))) {
                         throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $current_dir, base_convert($mode, 10, 8)));
                     }
                 }
             }
         }
     } else {
         if (!($action = @mkdir($pathname, $mode, true))) {
             throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $pathname, base_convert($mode, 10, 8)));
         }
     }
     return $action;
 }
开发者ID:just-paja,项目名称:fudjan,代码行数:39,代码来源:directory.php

示例15: __construct

 /**
  * Constructor for the Anthologize class
  *
  * This constructor does the following:
  * - Checks minimum PHP and WP version, and bails if they're not met
  * - Includes Anthologize's main files
  * - Sets up the basic hooks that initialize Anthologize's post types and UI
  *
  * @since 0.7
  */
 public function __construct()
 {
     // Bail if PHP version is not at least 5.0
     if (!self::check_minimum_php()) {
         add_action('admin_notices', array('Anthologize', 'phpversion_nag'));
         return;
     }
     // Bail if WP version is not at least 3.3
     if (!self::check_minimum_wp()) {
         add_action('admin_notices', array('Anthologize', 'wpversion_nag'));
     }
     // If we've made it this far, start initializing Anthologize
     register_activation_hook(__FILE__, array($this, 'activation'));
     register_deactivation_hook(__FILE__, array($this, 'deactivation'));
     // @todo WP's functions plugin_basename() etc don't work
     //   correctly on symlinked setups, so I'm implementing my own
     $bn = explode(DIRECTORY_SEPARATOR, dirname(__FILE__));
     $this->basename = array_pop($bn);
     $this->plugin_dir = plugin_dir_path(__FILE__);
     $this->plugin_url = plugin_dir_url(__FILE__);
     $this->includes_dir = trailingslashit($this->plugin_dir . 'includes');
     $upload_dir = wp_upload_dir();
     $this->cache_dir = trailingslashit($upload_dir['basedir'] . '/anthologize-cache');
     $this->cache_url = trailingslashit($upload_dir['baseurl'] . '/anthologize-cache');
     $this->setup_constants();
     $this->includes();
     $this->setup_hooks();
 }
开发者ID:webremote,项目名称:anthologize,代码行数:38,代码来源:anthologize.php


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