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


PHP prev函数代码示例

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


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

示例1: getPostageAmount

 /**
  * @param $areaId
  * @param $weight
  *
  * @return mixed
  * @throws \Thelia\Exception\OrderException
  */
 public static function getPostageAmount($areaId, $weight)
 {
     $freeshipping = ColissimoFreeshippingQuery::create()->getLast();
     $postage = 0;
     if (!$freeshipping) {
         $prices = self::getPrices();
         /* check if Colissimo delivers the asked area */
         if (!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
             throw new DeliveryException(Translator::getInstance()->trans("Colissimo delivery unavailable for the delivery country", [], self::MESSAGE_DOMAIN));
         }
         $areaPrices = $prices[$areaId]["slices"];
         ksort($areaPrices);
         /* Check cart weight is below the maximum weight */
         end($areaPrices);
         $maxWeight = key($areaPrices);
         if ($weight > $maxWeight) {
             throw new DeliveryException(Translator::getInstance()->trans("Colissimo delivery unavailable for this cart weight (%weight kg)", array("%weight" => $weight), self::MESSAGE_DOMAIN));
         }
         $postage = current($areaPrices);
         while (prev($areaPrices)) {
             if ($weight > key($areaPrices)) {
                 break;
             }
             $postage = current($areaPrices);
         }
     }
     return $postage;
 }
开发者ID:Mertiozys,项目名称:Colissimo,代码行数:35,代码来源:Colissimo.php

示例2: getPostageAmount

 /**
  * @param $areaId
  * @param $weight
  *
  * @return mixed
  * @throws DeliveryException
  */
 public static function getPostageAmount($areaId, $weight)
 {
     $freeshipping = @(bool) ConfigQuery::read("predict_freeshipping");
     $postage = 0;
     if (!$freeshipping) {
         $prices = static::getPrices();
         /* check if Predict delivers the asked area */
         if (!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
             throw new DeliveryException("Predict delivery unavailable for the chosen delivery country");
         }
         $areaPrices = $prices[$areaId]["slices"];
         ksort($areaPrices);
         /* check this weight is not too much */
         end($areaPrices);
         $maxWeight = key($areaPrices);
         if ($weight > $maxWeight) {
             throw new DeliveryException(sprintf("Predict delivery unavailable for this cart weight (%s kg)", $weight));
         }
         $postage = current($areaPrices);
         while (prev($areaPrices)) {
             if ($weight > key($areaPrices)) {
                 break;
             }
             $postage = current($areaPrices);
         }
     }
     return $postage;
 }
开发者ID:lopes-vincent,项目名称:Predict,代码行数:35,代码来源:PricesQuery.php

示例3: getSourceText

 public function getSourceText()
 {
     if ($this->getDiffSource() == false) {
         $c = new Criteria();
         $c->add("source_id", $this->getSourceId());
         $source = DB_PageSourcePeer::instance()->selectOne($c);
         return $source->getText();
     } else {
         // select last revisions and sources.
         $q = "SELECT page_source.* FROM page_source, page_revision WHERE " . "page_revision.page_id =" . $this->getPageId() . " " . "AND page_revision.revision_id <= " . $this->getRevisionId() . " " . "AND (page_revision.flag_text = TRUE OR page_revision.flag_new = TRUE) " . "AND page_revision.source_id = page_source.source_id " . "ORDER BY page_revision.revision_id DESC " . "LIMIT " . ($this->getSinceFullSource() + 1);
         $c = new Criteria();
         $c->setExplicitQuery($q);
         $sources = DB_PageSourcePeer::instance()->select($c);
         // original source...
         $s = end($sources);
         $s0 = $s->getText();
         $differ = new ODiff();
         while ($s = prev($sources)) {
             $s0 = $differ->patchString($s0, $s->getText());
             if ($differ->getErrors() != null) {
                 return "Error processing the source - please report the problem to the support";
             }
         }
         return trim($s0);
     }
 }
开发者ID:jbzdak,项目名称:wikidot,代码行数:26,代码来源:DB_PageRevision.php

示例4: check_base

 /**
  * Check and correct URL
  * @param string $url
  * @return string
  */
 public function check_base($url, $options)
 {
     if (!is_string($url) || empty($url)) {
         return $url;
     }
     global $wp_rewrite;
     $base_defined = $options->base_defined;
     $permastruct = $wp_rewrite->get_extra_permastruct($options->get_tax_query());
     if ($permastruct) {
         $permastruct = explode('/', $permastruct);
         end($permastruct);
         $permastruct = prev($permastruct);
         if (false !== $permastruct) {
             $base_defined = $permastruct;
         }
     }
     $base_option = get_option($options->base_option);
     if (empty($base_option)) {
         $base_option = $options->base_defined;
     }
     if ($base_defined != $base_option) {
         $search = '/' . $base_defined . '/';
         $replace = '/' . $base_option . '/';
         $count = 1;
         $url = str_replace($search, $replace, $url, $count);
     }
     return $url;
 }
开发者ID:laishidua,项目名称:laishidua.com,代码行数:33,代码来源:MslsOptionsTaxTerm.php

示例5: __construct

 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $groupId = $params->additionalParamList['entityId'];
     $userId = OW::getUser()->getId();
     $service = GROUPS_BOL_Service::getInstance();
     $feedService = GROUPRSS_BOL_FeedService::getInstance();
     $whoCanAdd = OW::getConfig()->getValue('grouprss', 'actionMember');
     if ($whoCanAdd == 'admin' && !OW::getUser()->isAdmin()) {
         $this->setVisible(false);
         return;
     }
     $mypaths = explode("/", UTIL_Url::selfUrl());
     $groupId = strtolower(end($mypaths));
     if ($groupId == 'customize') {
         $groupId = strtolower(prev($mypaths));
     }
     if ($whoCanAdd == 'creator' && $feedService->getGroupCreater($groupId) !== $userId) {
         $this->setVisible(false);
         return;
     }
     if ($whoCanAdd == 'both') {
         if (!OW::getUser()->isAdmin() && $feedService->getGroupCreater($groupId) !== $userId) {
             $this->setVisible(false);
             return;
         }
     }
     $this->assign('groupId', (int) $groupId);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:29,代码来源:manage_feeds_widget.php

示例6: format

 public function format($source)
 {
     $this->tkns = token_get_all($source);
     $this->code = '';
     while (list($index, $token) = each($this->tkns)) {
         list($id, $text) = $this->getToken($token);
         $this->ptr = $index;
         switch ($id) {
             case T_NAMESPACE:
                 if ($this->rightUsefulTokenIs(T_NS_SEPARATOR)) {
                     break;
                 }
                 $this->appendCode($text);
                 list($foundId, $foundText) = $this->printAndStopAt([ST_CURLY_OPEN, ST_SEMI_COLON]);
                 if (ST_CURLY_OPEN == $foundId) {
                     $this->appendCode($foundText);
                     $this->printCurlyBlock();
                 } elseif (ST_SEMI_COLON == $foundId) {
                     $this->appendCode(ST_CURLY_OPEN);
                     list($foundId, $foundText) = $this->printAndStopAt([T_NAMESPACE, T_CLOSE_TAG]);
                     if (T_CLOSE_TAG == $foundId) {
                         return $source;
                     }
                     $this->appendCode($this->getCrlf() . ST_CURLY_CLOSE . $this->getCrlf());
                     prev($this->tkns);
                     continue;
                 }
                 break;
             default:
                 $this->appendCode($text);
         }
     }
     return $this->code;
 }
开发者ID:studiokiwik,项目名称:php.tools,代码行数:34,代码来源:EncapsulateNamespaces.php

示例7: loadData

 /**
  * Load the data
  */
 private function loadData()
 {
     // get the current page id
     $pageId = $this->getContainer()->get('page')->getId();
     $navigation = FrontendNavigation::getNavigation();
     $pageInfo = FrontendNavigation::getPageInfo($pageId);
     $this->navigation = array();
     if (isset($navigation['page'][$pageInfo['parent_id']])) {
         $pages = $navigation['page'][$pageInfo['parent_id']];
         // store
         $pagesPrev = $pages;
         $pagesNext = $pages;
         // check for current id
         foreach ($pagesNext as $key => $value) {
             if ((int) $key != (int) $pageId) {
                 // go to next pointer in array
                 next($pagesNext);
                 next($pagesPrev);
             } else {
                 break;
             }
         }
         // get previous page
         $this->navigation['previous'] = prev($pagesPrev);
         // get next page
         $this->navigation['next'] = next($pagesNext);
         // get parent page
         $this->navigation['parent'] = FrontendNavigation::getPageInfo($pageInfo['parent_id']);
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:33,代码来源:PreviousNextNavigation.php

示例8: prev

 public function prev()
 {
     if (!prev($this->filters)) {
         end($this->filters);
     }
     return current($this->filters);
 }
开发者ID:p-m-d,项目名称:infiltrate,代码行数:7,代码来源:FilterCollection.php

示例9: processCliOptions

 /**
  * Processes command line options.
  *
  * @param array $options
  * @return \ApiGen\Config
  */
 public function processCliOptions(array $options)
 {
     while ($option = current($options)) {
         if (preg_match('~^--([a-z][-a-z]*[a-z])(?:=(.+))?$~', $option, $matches) || preg_match('~^-([a-z])=?(.*)~', $option, $matches)) {
             $name = $matches[1];
             if (!empty($matches[2])) {
                 $value = $matches[2];
             } else {
                 $next = next($options);
                 if (false === $next || '-' === $next[0]) {
                     prev($options);
                     $value = '';
                 } else {
                     $value = $next;
                 }
             }
             $this->options[$name][] = $value;
         }
         next($options);
     }
     $this->options = array_map(function ($value) {
         return 1 === count($value) ? $value[0] : $value;
     }, $this->options);
     // Compatibility with ApiGen 1.0
     foreach (array('config', 'source', 'destination') as $option) {
         if (isset($this->options[$option[0]]) && !isset($this->options[$option])) {
             $this->options[$option] = $this->options[$option[0]];
         }
         unset($this->options[$option[0]]);
     }
     return $this;
 }
开发者ID:anagio,项目名称:woocommerce,代码行数:38,代码来源:Config.php

示例10: examineStateChange

 public function examineStateChange(&$sToken, ParseState $aParseState)
 {
     if ($sToken !== 'TABLE' and $sToken !== 'TABLES') {
         return false;
     }
     $aParseState->arrTree[] = $sToken;
     $sOriToken = $sToken;
     // IF NOT EXISTS
     $arrTokenList = array('IF', 'NOT', 'EXISTS');
     while (1) {
         $sToken = next($aParseState->arrTokenList);
         if (empty($arrTokenList) or array_shift($arrTokenList) !== $sToken) {
             break;
         }
         $aParseState->arrTree[] = $sToken;
     }
     // 到头了, table/tables 后面没有内容
     if ($sToken === false) {
         prev($aParseState->arrTokenList);
         array_pop($aParseState->arrTree);
         $sToken = $sOriToken;
         return false;
     } else {
         if (strtolower($sToken) === 'status') {
             $aParseState->arrTree[] = $sToken;
             $sToken = next($aParseState->arrTokenList);
         }
     }
     // 遇到 TABLE ,检查下一个token 是否是有效的表名
     // $sToken = next($aParseState->arrTokenList) ;
     return parent::examineStateChange($sToken, $aParseState);
 }
开发者ID:JeCat,项目名称:framework,代码行数:32,代码来源:TableKeywordParser.php

示例11: process

 public function process()
 {
     $f = $this->modx->getOption(xPDO::OPT_CACHE_PATH) . 'logs/error.log';
     $content = '';
     $tooLarge = false;
     $size = 0;
     $empty = true;
     if (file_exists($f)) {
         $size = round(@filesize($f) / 1000 / 1000, 2);
         $content = @file_get_contents($f);
         if ($size > 1) {
             $tooLarge = true;
             $lines = preg_split('/\\r\\n?|\\n/', $content);
             $content = end($lines);
             for ($i = 1; $i < $this->getProperty('last', 10); $i++) {
                 $content = prev($lines) . "\n" . $content;
             }
         }
         unset($lines);
     }
     if (mb_strlen(trim($content)) > 0 || $tooLarge) {
         $empty = false;
     }
     $connector_url = $this->modx->getOption('assets_url') . 'components/controlerrorlog/connector.php';
     $la = array('name' => $f, 'log' => $content, 'tooLarge' => $tooLarge, 'size' => $size, 'empty' => $empty, 'last' => $this->getProperty('last'), 'connector_url' => $connector_url);
     return $this->success('', $la);
 }
开发者ID:vierkantemeter,项目名称:controlErrorLog,代码行数:27,代码来源:get.class.php

示例12: solution

function solution($A)
{
    // we sort array $A in ascending order from minimum to maximum integer; if closest integers
    // don't fullfill triangular conditions, farther integers will not fulfill it also
    // index association is not maintained because rule 0 ≤ P < Q < R < N is not important;
    // namely the following rules cover every possible combination:
    // A[P] + A[Q] > A[R]
    // A[Q] + A[R] > A[P]
    // A[R] + A[P] > A[Q]
    sort($A);
    $N = count($A);
    $arrayEnd = false;
    // while we haven't reached array end
    while (!$arrayEnd) {
        $P = key($A);
        // advance the internal array pointer of an array
        next($A);
        $Q = key($A);
        next($A);
        $R = key($A);
        // if $Q and $R exist, we haven't reached array $A end
        if ($Q !== NULL && $R !== NULL) {
            // rewind the internal array pointer 1 place back
            prev($A);
            // if triangular conditions are matched
            if ($A[$P] + $A[$Q] > $A[$R] && $A[$Q] + $A[$R] > $A[$P] && $A[$R] + $A[$P] > $A[$Q]) {
                return 1;
            }
        } else {
            $arrayEnd = true;
        }
    }
    return 0;
}
开发者ID:mgd-php,项目名称:php-codility,代码行数:34,代码来源:Triangle.php

示例13: postProcessSignOff

 public function postProcessSignOff()
 {
     if ($this->checkObjectClassTypeCorrect("SignOff") == true) {
         $signOff = end($this->stack);
         // get the previous object of the stack
         $currentRecord = prev($this->stack);
         // reset stack pointer to end
         end($this->stack);
         // Signing off of the wrong type of record, this is an error! Log it and continue
         if ($currentRecord->getRegistryEntryType() !== Constants::REGISTRY_ENTRY_TYPE_INCOMING) {
             $this->logger->warn('The following RegistryEntry has been signedOff, but it is not specified as Incoming (' . Constants . REGISTRY_ENTRY_TYPE_INCOMING . '). The actual RegistryEntry is ' . $currentRecord . ' while the signOff is ' . $signOff . ' This message is coming from ' . __METHOD__);
             $this->errorsEncountered = true;
             $this->numberErrorsEncountered++;
         }
         if (isset($this->listOfRegistryEntryIncoming[$currentRecord->getSystemId()])) {
             unset($this->listOfRegistryEntryIncoming[$currentRecord->getSystemId()]);
         } else {
             $this->logger->warn('Encountered a sigoff for the following RegistryEntry, but am not expecting this RegistryEntry. The actual RegistryEntry is ' . $currentRecord . ' while the signOff is ' . $signOff . ' This message is coming from ' . __METHOD__);
             $this->errorsEncountered = true;
             $this->numberErrorsEncountered++;
         }
         $this->logger->trace('Post process SignOff. Method (' . __METHOD__ . ')' . $signOff);
     } else {
         throw new Exception(Constants::STACK_ERROR . __METHOD__ . ". Expected SignOff found " . get_class(end($this->stack)));
     }
 }
开发者ID:HaakonME,项目名称:noark5-validator,代码行数:26,代码来源:AllIncomingRegistryEntrySignedOff.php

示例14: prev

 /**
  * @return bool, moves the internal array pointer backward one place.
  *                  Returns true, or false if there is no more element before the current pointer.
  */
 public function prev()
 {
     if (false !== prev($this->array)) {
         return true;
     }
     return false;
 }
开发者ID:lingtalfi,项目名称:TokenFun,代码行数:11,代码来源:TokenArrayIterator.php

示例15: parseArguments

 /**
  * Processes and returns command line arguments.
  *
  * @param array $argv Command line arguments
  * @return array
  * @todo Throw exception if an unexpected argument is found
  */
 public function parseArguments(array $argv)
 {
     $options = array();
     while ($argument = current($argv)) {
         if (preg_match('~^--([a-z][-a-z]*[a-z])(?:=(.+))?$~', $argument, $matches) || preg_match('~^-([a-z])=?(.*)~', $argument, $matches)) {
             $name = $matches[1];
             if (!empty($matches[2])) {
                 $value = $matches[2];
             } else {
                 $next = next($argv);
                 if (false === $next || '-' === $next[0]) {
                     prev($argv);
                     $value = '';
                 } else {
                     $value = $next;
                 }
             }
             $options[$name][] = $value;
         }
         next($argv);
     }
     $options = array_map(function ($value) {
         return 1 === count($value) ? $value[0] : $value;
     }, $options);
     return $options;
 }
开发者ID:memopower,项目名称:cakephp-api-docs,代码行数:33,代码来源:ConsoleParser.php


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