• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP strcspn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: load_class

 /**
  * @desc Called by the autoload engine to load a specific class must return true on success,
  * or false if class is not found
  * @param string $class_name - a class to load
  * @param bool $test_only - if true, do not actually load class, only check if it is present
  * @return bool
  */
 public function load_class($class_name, $test_only = false)
 {
     if (strcspn($class_name, "#=\"\\?*:/@|<>.\$") != strlen($class_name)) {
         die("Invalid class name: [{$class_name}]");
     }
     $prefix = $this->prefix;
     // check if the class belongs to our namespace:
     if (substr($class_name, 0, strlen($prefix)) == $prefix) {
         $class_name2 = substr($class_name, strlen($prefix));
     } else {
         return false;
     }
     $file = "{$this->path}/{$class_name}.class.php";
     if (!file_exists($file)) {
         $file = "{$this->path}/{$class_name2}.class.php";
     }
     if (file_exists($file)) {
         if (!$test_only) {
             include $file;
         }
         return true;
     }
     // Maybe this is an interface?
     $file = "{$this->path}/{$class_name}.interface.php";
     if (!file_exists($file)) {
         $file = "{$this->path}/{$class_name2}.interface.php";
     }
     if (file_exists($file)) {
         if (!$test_only) {
             include $file;
         }
         return true;
     }
     return false;
 }
开发者ID:laiello,项目名称:pkgmanager,代码行数:42,代码来源:pkgman_package.class.php


示例2: nextToken

 /**
  * Returns the next token from this tokenizer's string
  *
  * @param   bool delimiters default NULL
  * @return  string next token
  */
 public function nextToken($delimiters = null)
 {
     if (empty($this->_stack)) {
         // Read until we have either find a delimiter or until we have
         // consumed the entire content.
         do {
             $offset = strcspn($this->_buf, $delimiters ? $delimiters : $this->delimiters);
             if ($offset < strlen($this->_buf) - 1) {
                 break;
             }
             if (null === ($buf = $this->source->read())) {
                 break;
             }
             $this->_buf .= $buf;
         } while (true);
         if (!$this->returnDelims || $offset > 0) {
             $this->_stack[] = substr($this->_buf, 0, $offset);
         }
         $l = strlen($this->_buf);
         if ($this->returnDelims && $offset < $l) {
             $this->_stack[] = $this->_buf[$offset];
         }
         $offset++;
         $this->_buf = $offset < $l ? substr($this->_buf, $offset) : false;
     }
     return array_shift($this->_stack);
 }
开发者ID:xp-framework,项目名称:tokenize,代码行数:33,代码来源:TextTokenizer.class.php


示例3: getPositionFirstVowel

 public function getPositionFirstVowel($word)
 {
     if (empty($word) || !is_string($word)) {
         throw new \InvalidArgumentException(__FILE__ . ':' . __LINE__ . ': Invalid word, it must be a string, got :' . var_export($word, true));
     }
     return strcspn(strtolower($word), self::VOWEL);
 }
开发者ID:priscille-q,项目名称:pigLatinTranslator,代码行数:7,代码来源:Parser.php


示例4: getUserBytes

function getUserBytes($user)
{
    global $ipfw_offset;
    global $ipfw;
    global $UserBytes;
    $ipfw_rule = $ipfw_offset + $user;
    $RuleNum1 = 0;
    if (!count($UserBytes)) {
        $ftext = array();
        exec($ipfw . ' show', $ftext);
        for ($i = 0; $i < count($ftext); $i++) {
            $strTmp = trim($ftext[$i]);
            $len = strcspn($strTmp, " ");
            $RuleNum = substr($strTmp, 0, $len);
            $strTmp = trim(substr_replace($strTmp, " ", 0, $len));
            $len = strcspn($strTmp, " ");
            $CountPakets = substr($strTmp, 0, $len);
            $strTmp = trim(substr_replace($strTmp, " ", 0, $len));
            $len = strcspn($strTmp, " ");
            $CountBytes = substr($strTmp, 0, $len);
            if ($RuleNum1 != $RuleNum) {
                $RuleNum1 = $RuleNum;
                $UserBytes[$RuleNum] = $CountBytes;
            }
        }
    }
    return isset($UserBytes[$ipfw_rule]) ? $UserBytes[$ipfw_rule] : false;
}
开发者ID:nagyistoce,项目名称:lanmediaservice-lms-video-ce-1.x,代码行数:28,代码来源:shaper.php


示例5: getHostInfo

 public function getHostInfo($schema = '')
 {
     if ($this->_hostInfo === null) {
         if ($secure = $this->getIsSecureConnection()) {
             $http = 'https';
         } else {
             $http = 'http';
         }
         if (isset($_SERVER['HTTP_HOST'])) {
             $this->_hostInfo = $http . '://' . $_SERVER['HTTP_HOST'];
         } else {
             $this->_hostInfo = $http . '://' . $_SERVER['SERVER_NAME'];
             $port = $secure ? $this->getSecurePort() : $this->getPort();
             if ($port !== 80 && !$secure || $port !== 443 && $secure) {
                 $this->_hostInfo .= ':' . $port;
             }
         }
     }
     if ($schema !== '') {
         $secure = $this->getIsSecureConnection();
         if ($secure && $schema === 'https' || !$secure && $schema === 'http') {
             return $this->_hostInfo;
         }
         $port = $schema === 'https' ? $this->getSecurePort() : $this->getPort();
         if ($port !== 80 && $schema === 'http' || $port !== 443 && $schema === 'https') {
             $port = ':' . $port;
         } else {
             $port = '';
         }
         $pos = strpos($this->_hostInfo, ':');
         return $schema . substr($this->_hostInfo, $pos, strcspn($this->_hostInfo, ':', $pos + 1) + 1) . $port;
     } else {
         return $this->_hostInfo;
     }
 }
开发者ID:RandomCivil,项目名称:tiny-yii,代码行数:35,代码来源:CHttpRequest.php


示例6: match

 public function match($source, &$pos)
 {
     $sourceLength = strlen($source);
     for (; $pos < $sourceLength; $pos++) {
         $pos += strcspn($source, $this->firstChars, $pos);
         if ($pos == $sourceLength) {
             return false;
         }
         foreach ($this->stdTags as $tagIndex => $tag) {
             $this->tagLength = strlen($tag);
             if ($pos + $this->tagLength <= $sourceLength && substr_compare($source, $tag, $pos, $this->tagLength) === 0) {
                 $pos += $this->tagLength;
                 $this->tagIndex = $tagIndex;
                 $this->isStdTag = true;
                 return true;
             }
         }
         foreach ($this->userTags as $tagIndex => $tag) {
             $this->tagLength = strlen($tag);
             if ($pos + $this->tagLength <= $sourceLength && substr_compare($source, $tag, $pos, $this->tagLength) === 0) {
                 $pos += $this->tagLength;
                 $this->tagIndex = $tagIndex;
                 $this->isStdTag = false;
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:ljarray,项目名称:dbpedia,代码行数:29,代码来源:Matcher.php


示例7: export

 /**
  * Export a literal as an XPath expression
  *
  * @param  string $str Literal, e.g. "foo"
  * @return string      XPath expression, e.g. "'foo'"
  */
 public static function export($str)
 {
     // foo becomes 'foo'
     if (strpos($str, "'") === false) {
         return "'" . $str . "'";
     }
     // d'oh becomes "d'oh"
     if (strpos($str, '"') === false) {
         return '"' . $str . '"';
     }
     // This string contains both ' and ". XPath 1.0 doesn't have a mechanism to escape quotes,
     // so we have to get creative and use concat() to join chunks in single quotes and chunks
     // in double quotes
     $toks = [];
     $c = '"';
     $pos = 0;
     while ($pos < strlen($str)) {
         $spn = strcspn($str, $c, $pos);
         if ($spn) {
             $toks[] = $c . substr($str, $pos, $spn) . $c;
             $pos += $spn;
         }
         $c = $c === '"' ? "'" : '"';
     }
     return 'concat(' . implode(',', $toks) . ')';
 }
开发者ID:CryptArc,项目名称:TextFormatter,代码行数:32,代码来源:XPathHelper.php


示例8: parse_query

function parse_query($submitted_query)
{
    $query = explode(' ', $submitted_query);
    if (strcspn($query[0], '0123456789') == strlen($query[0])) {
        # One word book title (ie. Jacob, James, Matthew)
        $book = $query[0];
        $chapter = $query[1];
        if ($query[1] && strcspn($query[1], '0123456789') == strlen($query[1])) {
            # Two word book title (ie. Solomon's Song)
            $book .= ' ' . $query[1];
            $chapter = $query[2];
            if ($query[2] && strcspn($query[2], '0123456789') == strlen($query[2])) {
                # Three word book title (ie. Doctrine and Covenants, Words of Mormon)
                $book .= ' ' . $query[2];
                $chapter = $query[3];
            }
        }
    }
    if (strcspn($query[0], '0123456789') != strlen($query[0])) {
        # Book that starts with a number (ie. 1 Nephi, 2 Corinthians, 3 John)
        $book = $query[0] . ' ' . $query[1];
        $chapter = $query[2];
    }
    $get_verse = explode(':', $chapter);
    $result['book'] = $book;
    $result['chapter'] = $get_verse[0];
    $result['verse'] = $get_verse[1];
    return $result;
}
开发者ID:andrewheiss,项目名称:scriptures,代码行数:29,代码来源:getScriptureURL.php


示例9: _matchHttpAcceptLanguages

 /**
  * Tries to match the prefered language out of the http_accept_language string 
  * with one of the available languages.
  *
  * @private
  * @param httpAcceptLanguage the value of $_SERVER['HTTP_ACCEPT_LANGUAGE']
  * @return Returns returns prefered language or false if no language matched.
  */
 function _matchHttpAcceptLanguages(&$httpAcceptLanguage)
 {
     $acceptedLanguages = explode(',', $httpAcceptLanguage);
     $availableLanguages =& Locales::getAvailableLocales();
     $primaryLanguageMatch = '';
     // we iterate through the array of languages sent by the UA and test every single
     // one against the array of available languages
     foreach ($acceptedLanguages as $acceptedLang) {
         // clean the string and strip it down to the language value (remove stuff like ";q=0.3")
         $acceptedLang = substr($acceptedLang, 0, strcspn($acceptedLang, ';'));
         if (strlen($acceptedLang) > 2) {
             // cut to primary language
             $primaryAcceptedLang = substr($acceptedLang, 0, 2);
         } else {
             $primaryAcceptedLang = $acceptedLang;
         }
         // this is where we start to iterate through available languages
         foreach ($availableLanguages as $availableLang) {
             if (stristr($availableLang, $acceptedLang) !== false) {
                 // we have a exact language match
                 return $availableLang;
             } elseif (stristr($availableLang, $primaryAcceptedLang) !== false && $primaryLanguageMatch == '') {
                 // we found the first primary language match!
                 $primaryLanguageMatch = $availableLang;
             }
         }
     }
     // foreach
     if ($primaryLanguageMatch != '') {
         return $primaryLanguageMatch;
     } else {
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:42,代码来源:summaryaction.class.php


示例10: parseInput

 protected function parseInput($native, &$pos)
 {
     $hasDelimiters = $angleDelimiter = $singleOpen = false;
     if ('<' === ($char = $this->nextChar($native, $pos)) || '(' === $char) {
         $hasDelimiters = true;
         if ('<' === $char) {
             $angleDelimiter = true;
         } else {
             $singleOpen = $pos === call_user_func(self::$strrpos, $native, '(');
         }
         $pos++;
     }
     $center = $this->point->parseInput($native, $pos);
     if (')' === $this->nextChar($native, $pos) && $singleOpen) {
         $hasDelimiters = false;
         $pos++;
     }
     $this->expectChar($native, $pos, ',');
     $len = strcspn($native, ',)>', $pos);
     $radius = call_user_func(self::$substr, $native, $pos, $len);
     $pos += $len;
     if ($hasDelimiters) {
         $this->expectChar($native, $pos, $angleDelimiter ? '>' : ')');
     }
     return new Circle($center, $this->_float->input($radius));
 }
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:26,代码来源:CircleConverter.php


示例11: createSitepageMaster

/**
 * Create a new Page Template
 * @param string Name
 * @param string Description
 * @param string Filename of the template
 * @param string Template
 * @param integer GUID of Cluster Template
 * @param integer Id of Type (1=singlepage, 2=multipage)
 * @param integer OPtional key to use.
 */
function createSitepageMaster($name, $description, $templatePath, $template, $clt, $type, $id = null)
{
    global $db, $c, $errors;
    if ($id == null) {
        $id = nextGUID();
    }
    $name = makeCopyName("sitepage_master", "NAME", parseSQL($name), "VERSION=0 AND DELETED=0");
    $description = parseSQL($description);
    $filename = substr($templatePath, 0, strcspn($templatePath, "."));
    $filesuffix = $templatePath = substr($templatePath, strcspn($templatePath, ".") + 1);
    $templatePath = makeUniqueFilename($c["devpath"], parseSQL($filename), $filesuffix);
    $fp = @fopen($c["devpath"] . $templatePath, "w+");
    if ($fp != "") {
        @fwrite($fp, $template);
        @fclose($fp);
    } else {
        $errors .= "--Could not write spm: " . $templatePath;
    }
    $sql = "INSERT INTO sitepage_master (SPM_ID, NAME, DESCRIPTION, TEMPLATE_PATH, CLT_ID, SPMTYPE_ID) VALUES ";
    $sql .= "({$id}, '{$name}', '{$description}', '{$templatePath}', {$clt}, {$type})";
    $query = new query($db, $sql);
    $query->free();
    $variations = createDBCArray("variations", "VARIATION_ID", "1");
    for ($i = 0; $i < count($variations); $i++) {
        $sql = "INSERT INTO sitepage_variations (SPM_ID, VARIATION_ID) VALUES ( {$id}, " . $variations[$i] . ")";
        $query = new query($db, $sql);
        $query->free();
    }
    return $id;
}
开发者ID:BackupTheBerlios,项目名称:nxwcms-svn,代码行数:40,代码来源:sitepage_master.php


示例12: stringToBin

 public function stringToBin($str)
 {
     $alpha = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,-";
     $nbits = 6;
     $length = strlen($str);
     $out = '';
     $at = 0;
     $rshift = 0;
     $char_in = 0;
     $char_out = chr(0);
     while (1) {
         $char_in = strcspn($alpha, $str[$at++]);
         if ($rshift > 0) {
             $char_out |= chr($char_in << 8 - $rshift);
             $out .= $char_out;
             $char_out = chr(0);
             if ($at >= $length) {
                 break;
             }
         }
         $char_out |= chr($char_in >> $rshift);
         $rshift += 2;
         if ($rshift === 8) {
             $rshift = 0;
         }
     }
     return $out;
 }
开发者ID:elementgreen,项目名称:affiliates-manager-plugin,代码行数:28,代码来源:BinConverter.php


示例13: format

 /**
  * Format a string containing `<styles>`...`</>` sequences
  *
  * @param  string $in
  * @param  string[] $stack
  * @return string
  */
 public static function format($in, &$stack)
 {
     $offset = 0;
     $length = strlen($in);
     $formatted = '';
     do {
         $p = strcspn($in, '<', $offset);
         $formatted .= substr($in, $offset, $p);
         $offset += $p + 1;
         if ($offset >= $length) {
             break;
         }
         $e = strcspn($in, '>', $offset);
         $token = substr($in, $offset, $e);
         if ('' === $token) {
             $e = strpos($in, '</>', $offset) - $offset;
             $formatted .= substr($in, $offset + 1, $e - 1);
             $e += 2;
         } else {
             if ('/' === $token[0]) {
                 $formatted .= array_pop($stack);
             } else {
                 if (strlen($token) !== strspn($token, 'abcdefghijklmnopqrstuvwxyz0123456789-,@')) {
                     $formatted .= substr($in, $offset - 1, $e + 1 + 1);
                 } else {
                     list($set, $unset) = Terminal::transition($token);
                     $formatted .= $set;
                     $stack[] = $unset;
                 }
             }
         }
         $offset += $e + 1;
     } while ($offset < $length);
     return $formatted;
 }
开发者ID:xp-forge,项目名称:terminal,代码行数:42,代码来源:Terminal.class.php


示例14: sql_compile_placeholder

function sql_compile_placeholder($tmpl)
{
    $compiled = array();
    $p = 0;
    $i = 0;
    $has_named = false;
    while (false !== ($start = $p = strpos($tmpl, "?", $p))) {
        switch ($c = substr($tmpl, ++$p, 1)) {
            case "%":
            case "@":
            case "#":
                $type = $c;
                ++$p;
                break;
            default:
                $type = "";
        }
        $len = strcspn(substr($tmpl, $p), " \t\r\n,;()[]/");
        if ($len) {
            $key = substr($tmpl, $p, $len);
            $has_named = true;
            $p += $len;
        } else {
            $key = $i++;
        }
        $compiled[] = array($key, $type, $start, $p - $start);
    }
    return array($compiled, $tmpl, $has_named);
}
开发者ID:gionniboy,项目名称:0x88,代码行数:29,代码来源:lib.placeholder.php


示例15: pair

 /**
  * Writes a pair
  *
  * @param  string $name
  * @param  [:string] $attributes
  * @param  var $value
  * @return void
  */
 public function pair($name, $attributes, $value)
 {
     if (is_array($value)) {
         foreach ($value as $element) {
             $this->pair($name, $attributes, $element);
         }
     } else {
         if ($value instanceof Object) {
             $value->write($this, $name);
         } else {
             if (null !== $value) {
                 $key = strtoupper($name);
                 foreach ($attributes as $name => $attribute) {
                     if (null === $attribute) {
                         continue;
                     } else {
                         if (strcspn($attribute, '=;:') < strlen($attribute)) {
                             $pair = strtoupper($name) . '="' . $attribute . '"';
                         } else {
                             $pair = strtoupper($name) . '=' . $attribute;
                         }
                     }
                     if (strlen($key) + strlen($pair) > self::WRAP) {
                         $this->writer->writeLine($key . ';');
                         $key = ' ' . $pair;
                     } else {
                         $key .= ';' . $pair;
                     }
                 }
                 $this->writer->writeLine(wordwrap($key . ':' . strtr($value, ["\n" => '\\n']), self::WRAP, "\r\n ", true));
             }
         }
     }
 }
开发者ID:xp-forge,项目名称:ical,代码行数:42,代码来源:Output.class.php


示例16: cleanupDeletedBatch

 /**
  * Delete files in the deleted directory if they are not referenced in the
  * filearchive table. This needs to be done in the repo because it needs to
  * interleave database locks with file operations, which is potentially a
  * remote operation.
  * @return FileRepoStatus
  */
 function cleanupDeletedBatch($storageKeys)
 {
     $root = $this->getZonePath('deleted');
     $dbw = $this->getMasterDB();
     $status = $this->newGood();
     $storageKeys = array_unique($storageKeys);
     foreach ($storageKeys as $key) {
         $hashPath = $this->getDeletedHashPath($key);
         $path = "{$root}/{$hashPath}{$key}";
         $dbw->begin();
         $inuse = $dbw->selectField('filearchive', '1', array('fa_storage_group' => 'deleted', 'fa_storage_key' => $key), __METHOD__, array('FOR UPDATE'));
         if (!$inuse) {
             $sha1 = substr($key, 0, strcspn($key, '.'));
             $ext = substr($key, strcspn($key, '.') + 1);
             $ext = File::normalizeExtension($ext);
             $inuse = $dbw->selectField('oldimage', '1', array('oi_sha1' => $sha1, 'oi_archive_name ' . $dbw->buildLike($dbw->anyString(), ".{$ext}"), $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE), __METHOD__, array('FOR UPDATE'));
         }
         if (!$inuse) {
             wfDebug(__METHOD__ . ": deleting {$key}\n");
             if (!@unlink($path)) {
                 $status->error('undelete-cleanup-error', $path);
                 $status->failCount++;
             }
         } else {
             wfDebug(__METHOD__ . ": {$key} still in use\n");
             $status->successCount++;
         }
         $dbw->commit();
     }
     return $status;
 }
开发者ID:rocLv,项目名称:conference,代码行数:38,代码来源:LocalRepo.php


示例17: parse

 /**
  * Parse an attribute value template
  *
  * @link http://www.w3.org/TR/xslt#dt-attribute-value-template
  *
  * @param  string $attrValue Attribute value
  * @return array             Array of tokens
  */
 public static function parse($attrValue)
 {
     $tokens = [];
     $attrLen = strlen($attrValue);
     $pos = 0;
     while ($pos < $attrLen) {
         // Look for opening brackets
         if ($attrValue[$pos] === '{') {
             // Two brackets = one literal bracket
             if (substr($attrValue, $pos, 2) === '{{') {
                 $tokens[] = ['literal', '{'];
                 $pos += 2;
                 continue;
             }
             // Move the cursor past the left bracket
             ++$pos;
             // We're inside an inline XPath expression. We need to parse it in order to find
             // where it ends
             $expr = '';
             while ($pos < $attrLen) {
                 // Capture everything up to the next "interesting" char: ', " or }
                 $spn = strcspn($attrValue, '\'"}', $pos);
                 if ($spn) {
                     $expr .= substr($attrValue, $pos, $spn);
                     $pos += $spn;
                 }
                 if ($pos >= $attrLen) {
                     throw new RuntimeException('Unterminated XPath expression');
                 }
                 // Capture the character then move the cursor
                 $c = $attrValue[$pos];
                 ++$pos;
                 if ($c === '}') {
                     // Done with this expression
                     break;
                 }
                 // Look for the matching quote
                 $quotePos = strpos($attrValue, $c, $pos);
                 if ($quotePos === false) {
                     throw new RuntimeException('Unterminated XPath expression');
                 }
                 // Capture the content of that string then move the cursor past it
                 $expr .= $c . substr($attrValue, $pos, $quotePos + 1 - $pos);
                 $pos = 1 + $quotePos;
             }
             $tokens[] = ['expression', $expr];
         }
         $spn = strcspn($attrValue, '{', $pos);
         if ($spn) {
             // Capture this chunk of attribute value
             $str = substr($attrValue, $pos, $spn);
             // Unescape right brackets
             $str = str_replace('}}', '}', $str);
             // Add the value and move the cursor
             $tokens[] = ['literal', $str];
             $pos += $spn;
         }
     }
     return $tokens;
 }
开发者ID:CryptArc,项目名称:TextFormatter,代码行数:68,代码来源:AVTHelper.php


示例18: selfURLhost

 /**
  * Will return https://sp.example.org[:PORT]
  */
 public static function selfURLhost()
 {
     $url = self::getBaseURL();
     $start = strpos($url, '://') + 3;
     $length = strcspn($url, '/', $start) + $start;
     return substr($url, 0, $length);
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:10,代码来源:Utilities.php


示例19: getBrowserLangCode

 public function getBrowserLangCode($system_langs)
 {
     $lang = null;
     if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         return $lang;
     }
     $browser_langs = explode(',', $this->request->server['HTTP_ACCEPT_LANGUAGE']);
     foreach ($browser_langs as $browser_lang) {
         // Slice out the part before ; on first step, the part before - on second, place into array
         $browser_lang = substr($browser_lang, 0, strcspn($browser_lang, ';'));
         $primary_browser_lang = substr($browser_lang, 0, 2);
         foreach ($system_langs as $system_lang) {
             if (!$system_lang['status']) {
                 continue;
             }
             $system_code = $system_lang['code'];
             $system_dir = $system_lang['directory'];
             // Take off 3 letters (zh-yue) iso code languages as they can't match browsers' languages and default them to en
             // http://www.w3.org/International/articles/language-tags/#extlang
             if (strlen($system_dir) > 5) {
                 continue;
             }
             if (strtolower($browser_lang) == strtolower(substr($system_dir, 0, strlen($browser_lang)))) {
                 return $system_code;
             } elseif ($primary_browser_lang == substr($system_dir, 0, 2)) {
                 $primary_detected_code = $system_code;
             }
         }
         if (isset($primary_detected_code)) {
             return $primary_detected_code;
         }
     }
     return $lang;
 }
开发者ID:LinuxJedi,项目名称:arastta,代码行数:34,代码来源:utility.php


示例20: parse

 /**
  * Parses a DNUMBER token like PHP would.
  *
  * @param string $str A string number
  *
  * @return float The parsed number
  */
 public static function parse($str)
 {
     // if string contains any of .eE just cast it to float
     if (false !== strpbrk($str, '.eE')) {
         return (double) $str;
     }
     // otherwise it's an integer notation that overflowed into a float
     // if it starts with 0 it's one of the special integer notations
     if ('0' === $str[0]) {
         // hex
         if ('x' === $str[1] || 'X' === $str[1]) {
             return hexdec($str);
         }
         // bin
         if ('b' === $str[1] || 'B' === $str[1]) {
             return bindec($str);
         }
         // oct
         // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9)
         // so that only the digits before that are used
         return octdec(substr($str, 0, strcspn($str, '89')));
     }
     // dec
     return (double) $str;
 }
开发者ID:ck-1,项目名称:PHP-Parser,代码行数:32,代码来源:DNumber.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP strcut函数代码示例发布时间:2022-05-23
下一篇:
PHP strcoll函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap