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


PHP array_shift函数代码示例

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


在下文中一共展示了array_shift函数的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: 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

示例3: _process

 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $m = $this->getConfig('methods');
     if (@count($m) == 1) {
         $a = new Am_Paysystem_Action_Form(self::URL . $m[0] . '/event/');
     } else {
         $a = new Am_Paysystem_Action_HtmlTemplate_Micropayment($this->getDir(), 'micropayment-confirm.phtml');
         $methods = array();
         if (@count($m)) {
             $a->url = self::URL . $m[0] . '/event/';
             foreach ($m as $title) {
                 $methods[self::URL . $title . '/event/'] = $this->getConfig($title . '.title');
             }
         } else {
             foreach ($this->getConfig() as $k => $v) {
                 if (is_array($v) && !empty($v['title'])) {
                     $methods[self::URL . $k . '/event/'] = $v['title'];
                 }
             }
             $a->url = array_shift(array_keys($methods));
         }
         $a->methods = $methods;
     }
     $a->project = $this->getConfig('project');
     $a->amount = $invoice->first_total * 100;
     $a->freepaymentid = $invoice->public_id;
     $a->seal = md5("project={$a->project}&amount={$a->amount}&freepaymentid={$a->freepaymentid}" . $this->getConfig('key'));
     $result->setAction($a);
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:29,代码来源:micropayment.php

示例4: assignfeedback_editpdf_pluginfile

/**
 * Serves assignment feedback and other files.
 *
 * @param mixed $course course or id of the course
 * @param mixed $cm course module or id of the course module
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @return bool false if file not found, does not return if found - just send the file
 */
function assignfeedback_editpdf_pluginfile($course, $cm, context $context, $filearea, $args, $forcedownload)
{
    global $USER, $DB, $CFG;
    if ($context->contextlevel == CONTEXT_MODULE) {
        require_login($course, false, $cm);
        $itemid = (int) array_shift($args);
        if (!($assign = $DB->get_record('assign', array('id' => $cm->instance)))) {
            return false;
        }
        $record = $DB->get_record('assign_grades', array('id' => $itemid), 'userid,assignment', MUST_EXIST);
        $userid = $record->userid;
        if ($assign->id != $record->assignment) {
            return false;
        }
        // Check is users feedback or has grading permission.
        if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) {
            return false;
        }
        $relativepath = implode('/', $args);
        $fullpath = "/{$context->id}/assignfeedback_editpdf/{$filearea}/{$itemid}/{$relativepath}";
        $fs = get_file_storage();
        if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
            return false;
        }
        // Download MUST be forced - security!
        send_stored_file($file, 0, 0, true);
        // Check if we want to retrieve the stamps.
    }
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:40,代码来源:lib.php

示例5: set

 public function set($var, $value = null)
 {
     // parse variable name
     extract($this->_parse($var));
     if (!empty($name)) {
         // set default hash to method
         if ($hash == 'default') {
             $hash = 'method';
         }
         // set a array value ?
         if (strpos($name, '.') !== false) {
             $parts = explode('.', $name);
             $name = array_shift($parts);
             $array =& $this->_call(array($this->_class, 'getVar'), array($name, array(), $hash, 'array'));
             $val =& $array;
             foreach ($parts as $i => $part) {
                 if (!isset($array[$part])) {
                     $array[$part] = array();
                 }
                 if (isset($parts[$i + 1])) {
                     $array =& $array[$part];
                 } else {
                     $array[$part] = $value;
                 }
             }
             $value = $val;
         }
         $this->_call(array($this->_class, 'setVar'), array($name, $value, $hash));
     }
     return $this;
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:31,代码来源:request.php

示例6: workshopform_numerrors_pluginfile

function workshopform_numerrors_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) {
    global $DB;

    if ($context->contextlevel != CONTEXT_MODULE) {
        return false;
    }

    require_login($course, true, $cm);

    if ($filearea !== 'description') {
        return false;
    }

    $itemid = (int)array_shift($args); // the id of the assessment form dimension
    if (!$workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
        send_file_not_found();
    }

    if (!$dimension = $DB->get_record('workshopform_numerrors', array('id' => $itemid ,'workshopid' => $workshop->id))) {
        send_file_not_found();
    }

    // TODO now make sure the user is allowed to see the file
    // (media embedded into the dimension description)

    $fs = get_file_storage();
    $relativepath = implode('/', $args);
    $fullpath = "/$context->id/workshopform_numerrors/$filearea/$itemid/$relativepath";
    if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
        return false;
    }

    // finally send the file
    send_stored_file($file);
}
开发者ID:nuckey,项目名称:moodle,代码行数:35,代码来源:lib.php

示例7: __construct

 /**
  * Sets validator options
  *
  * @param  integer|array|Zend_Config $options
  * @return void
  */
 public function __construct($options = array())
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     } else {
         if (!is_array($options)) {
             $options = func_get_args();
             $temp['min'] = array_shift($options);
             if (!empty($options)) {
                 $temp['max'] = array_shift($options);
             }
             if (!empty($options)) {
                 $temp['encoding'] = array_shift($options);
             }
             $options = $temp;
         }
     }
     if (!array_key_exists('min', $options)) {
         $options['min'] = 0;
     }
     $this->setMin($options['min']);
     if (array_key_exists('max', $options)) {
         $this->setMax($options['max']);
     }
     if (array_key_exists('encoding', $options)) {
         $this->setEncoding($options['encoding']);
     }
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:34,代码来源:StringLength.php

示例8: refine

 /**
  *
  */
 public function refine(&$pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options = null)
 {
     $o_log = isset($pa_options['log']) && is_object($pa_options['log']) ? $pa_options['log'] : null;
     // Set place hierarchy
     if ($vs_hierarchy = $pa_item['settings']['placeSplitter_placeHierarchy']) {
         $vn_hierarchy_id = caGetListItemID('place_hierarchies', $vs_hierarchy);
     } else {
         // Default to first place hierarchy
         $t_list = new ca_lists();
         $va_hierarchy_ids = $t_list->getItemsForList('place_hierarchies', array('idsOnly' => true));
         $vn_hierarchy_id = array_shift($va_hierarchy_ids);
     }
     if (!$vn_hierarchy_id) {
         if ($o_log) {
             $o_log->logError(_t('[placeSplitterRefinery] No place hierarchies are defined'));
         }
         return array();
     }
     $pa_options['hierarchyID'] = $vn_hierarchy_id;
     $t_place = new ca_places();
     if ($t_place->load(array('parent_id' => null, 'hierarchy_id' => $vn_hierarchy_id))) {
         $pa_options['defaultParentID'] = $t_place->getPrimaryKey();
     }
     return caGenericImportSplitter('placeSplitter', 'place', 'ca_places', $this, $pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:28,代码来源:placeSplitterRefinery.php

示例9: Scaffold_image_replace_matrix

function Scaffold_image_replace_matrix($params)
{
    if (preg_match_all('/\\([^)]*?,[^)]*?\\)/', $params, $matches)) {
        foreach ($matches as $key => $original) {
            $new = str_replace(',', '#COMMA#', $original);
            $params = str_replace($original, $new, $params);
        }
    }
    $params = explode(',', $params);
    foreach (array('url', 'width', 'height', 'x', 'y') as $key => $name) {
        ${$name} = trim(str_replace('#COMMA#', ',', array_shift($params)));
    }
    $url = preg_replace('/\\s+/', '', $url);
    $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url);
    if (!$x) {
        $x = 0;
    }
    if (!$y) {
        $y = 0;
    }
    $path = Scaffold::find_file($url);
    if ($path === false) {
        return false;
    }
    // Make sure theres a value so it doesn't break the css
    if (!$width && !$height) {
        $width = $height = 0;
    }
    // Build the selector
    $properties = "background:url(" . Scaffold::url_path($path) . ") no-repeat {$x}px {$y}px;\n\t\theight:{$height}px;\n\t\twidth:{$width}px;\n\t\tdisplay:block;\n\t\ttext-indent:-9999px;\n\t\toverflow:hidden;";
    return $properties;
}
开发者ID:behaba,项目名称:csscaffold,代码行数:32,代码来源:image-replace-matrix.php

示例10: redirectHome

 /**
  * Redirect to user home page (or the role home page if the user has one role).
  * @param $request PKPRequest the request to be routed
  */
 function redirectHome(&$request)
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $user = $request->getUser();
     $userId = $user->getId();
     if ($schedConf =& $this->getContext($request, 2)) {
         // The user is in the sched. conf. context, see if they have one role only
         $roles =& $roleDao->getRolesByUserId($userId, $schedConf->getConferenceId(), $schedConf->getId());
         if (count($roles) == 1) {
             $role = array_shift($roles);
             if ($role->getRoleId() == ROLE_ID_READER) {
                 $request->redirect(null, 'index');
             }
             $request->redirect(null, null, $role->getRolePath());
         } else {
             $request->redirect(null, null, 'user');
         }
     } elseif ($conference =& $this->getContext($request, 1)) {
         // The user is in the conference context, see if they have one role only
         $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
         $roles =& $roleDao->getRolesByUserId($userId, $conference->getId());
         if (count($roles) == 1) {
             $role = array_shift($roles);
             $confPath = $conference->getPath();
             $schedConfPath = 'index';
             if ($role->getSchedConfId()) {
                 $schedConf = $schedConfDao->getSchedConf($role->getSchedConfId());
                 $schedConfPath = $schedConf->getPath();
             }
             if ($role->getRoleId() == ROLE_ID_READER) {
                 $request->redirect($confPath, $schedConfPath, 'index');
             }
             $request->redirect($confPath, $schedConfPath, $role->getRolePath());
         } else {
             $request->redirect(null, null, 'user');
         }
     } else {
         // The user is at the site context, check to see if they are
         // only registered in one conf/SchedConf w/ one role
         $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
         $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
         $roles = $roleDao->getRolesByUserId($userId);
         if (count($roles) == 1) {
             $role = array_shift($roles);
             $confPath = 'index';
             $schedConfPath = 'index';
             if ($role->getConferenceId()) {
                 $conference = $conferenceDao->getConference($role->getConferenceId());
                 isset($conference) ? $confPath = $conference->getPath() : ($confPath = 'index');
             }
             if ($role->getSchedConfId()) {
                 $schedConf = $schedConfDao->getSchedConf($role->getSchedConfId());
                 isset($schedConf) ? $schedConfPath = $schedConf->getPath() : ($schedConfPath = 'index');
             }
             $request->redirect($confPath, $schedConfPath, $role->getRolePath());
         } else {
             $request->redirect('index', 'index', 'user');
         }
     }
 }
开发者ID:ramonsodoma,项目名称:ocs,代码行数:64,代码来源:PageRouter.inc.php

示例11: parseRequest

 /**
  * Parse the incoming request in a RESTful way
  *
  * @param \PASL\Web\Service\Request The request object
  */
 public function parseRequest($oRequest)
 {
     $oRequestData = array();
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'GET':
             $oRequestHash = $_REQUEST;
             break;
         case 'POST':
             $oRequestHash = $_REQUEST;
             break;
         case 'PUT':
             parse_str(file_get_contents("php://input"), $oRequestHash);
             break;
     }
     foreach ($oRequestHash as $val) {
         if (trim($val) != "" && !is_null($val)) {
             array_push($oRequest->oRequestHash, $val);
         }
     }
     $oRequest->requestPayload = $oRequestData;
     $oRequest->method = $oRequest->oRequestHash[2];
     // Grab the method arguments
     $methodArgs = $oRequest->oRequestHash;
     array_shift($methodArgs);
     array_shift($methodArgs);
     array_shift($methodArgs);
     $oRequest->methodArgs = $methodArgs;
     return $oRequest;
 }
开发者ID:how,项目名称:openpasl,代码行数:34,代码来源:REST.php

示例12: buildRoute

 public static function buildRoute($route)
 {
     $result = static::snakeCase(array_shift($route));
     return $result . join("", array_map(function ($e) {
         return "['" . Helpers::snakeCase($e) . "']";
     }, $route));
 }
开发者ID:yurykabanov,项目名称:xsd2blade,代码行数:7,代码来源:Helpers.php

示例13: __invoke

 /**
  * Expands a flat array to a nested array.
  *
  * For example, `['0_Foo_Bar' => 'Far']` becomes
  * `[['Foo' => ['Bar' => 'Far']]]`.
  *
  * @param array $environment Array of environment data
  * @return array
  */
 public function __invoke(array $environment)
 {
     $result = array();
     foreach ($environment as $flat => $value) {
         $keys = explode('_', $flat);
         $keys = array_reverse($keys);
         $child = array($keys[0] => $value);
         array_shift($keys);
         foreach ($keys as $k) {
             $child = array($k => $child);
         }
         $stack = array(array($child, &$result));
         while (!empty($stack)) {
             foreach ($stack as $curKey => &$curMerge) {
                 foreach ($curMerge[0] as $key => &$val) {
                     $hasKey = !empty($curMerge[1][$key]);
                     if ($hasKey && (array) $curMerge[1][$key] === $curMerge[1][$key] && (array) $val === $val) {
                         $stack[] = array(&$val, &$curMerge[1][$key]);
                     } else {
                         $curMerge[1][$key] = $val;
                     }
                 }
                 unset($stack[$curKey]);
             }
             unset($curMerge);
         }
     }
     return $result;
 }
开发者ID:linking-arts,项目名称:furry-goggles,代码行数:38,代码来源:UnderscoreArrayFilter.php

示例14: __

 /**
  * Translate a phrase
  *
  * @return string
  */
 public function __()
 {
     $args = func_get_args();
     $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getRealModuleName());
     array_unshift($args, $expr);
     return AO::app()->getTranslator()->translate($args);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:12,代码来源:Action.php

示例15: rawQueries

 protected function rawQueries(array $raw_queries)
 {
     $conn = $this->requireConnection();
     $have_result = false;
     $results = array();
     foreach ($raw_queries as $key => $raw_query) {
         if (!$have_result) {
             // End line in front of semicolon to allow single line comments at the
             // end of queries.
             $have_result = $conn->multi_query(implode("\n;\n\n", $raw_queries));
         } else {
             $have_result = $conn->next_result();
         }
         array_shift($raw_queries);
         $result = $conn->store_result();
         if (!$result && !$this->getErrorCode($conn)) {
             $result = true;
         }
         $results[$key] = $this->processResult($result);
     }
     if ($conn->more_results()) {
         throw new Exception(pht('There are some results left in the result set.'));
     }
     return $results;
 }
开发者ID:billtt,项目名称:libphutil,代码行数:25,代码来源:AphrontMySQLiDatabaseConnection.php


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