本文整理汇总了PHP中len函数的典型用法代码示例。如果您正苦于以下问题:PHP len函数的具体用法?PHP len怎么用?PHP len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了len函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: path2array_paquet
public static function path2array_paquet($_path, $lg1, $lg2, $mesure)
{
$array_lg = array($lg1, $lg2);
sort($array_lg);
$data = Tool_files::file_load($_path);
$f = Tool_files::csv2array_line($data, "\n");
$array_paquet = array();
$tmp = array();
$flag_vu = false;
foreach ($f as $line) {
if (mb_eregi("[:alnum:]", $line)) {
$tmp[] = trim($line);
} elseif (len($tmp) > 0) {
list($dist, $rep) = mb_split(" : ", $tmp[0]);
list($score, $l1, $l2) = mb_split(" ", $rep);
$score = trim($score);
$dist = trim($dist);
$l1 = trim($l1);
$l2 = trim($l2);
if ($dist == $mesure) {
if ($l1 == $lg2 and $l2 == $lg1 or $lg1 == $l1 and $lg2 == $l2) {
$flag_vu = true;
list($str1, $rep1) = self::line2str_rep($tmp[1]);
list($str2, $rep2) = self::line2str_rep($tmp[2]);
$array_paquet[] = array('score' => $score, $l1 => $rep1, $l2 => $rep2, "str_{$l1}" => $str1, "str_{$l2}" => $str2);
}
} elseif ($flag_vu) {
break;
}
$tmp = array();
}
}
return $array_paquet;
}
示例2: pad
/**
* UTF-8 aware alternative to str_pad.
*
* $pad_str may contain multi-byte characters.
*
* @author Oliver Saunders <oliver@osinternetservices.com>
* @package php-utf-8
* @subpackage functions
* @see http://www.php.net/str_pad
* @uses utf8_substr
*
* @param string $input
* @param int $length
* @param string $pad_str
* @param int $type (same constants as str_pad)
*
* @return string
*/
function pad($input, $length, $pad_str = ' ', $type = STR_PAD_RIGHT)
{
$input_len = len($input);
if ($length <= $input_len) {
return $input;
}
$pad_str_len = len($pad_str);
$pad_len = $length - $input_len;
if ($type == STR_PAD_RIGHT) {
$repeat_times = ceil($pad_len / $pad_str_len);
return sub($input . str_repeat($pad_str, $repeat_times), 0, $length);
}
if ($type == STR_PAD_LEFT) {
$repeat_times = ceil($pad_len / $pad_str_len);
return sub(str_repeat($pad_str, $repeat_times), 0, floor($pad_len)) . $input;
}
if ($type == STR_PAD_BOTH) {
$pad_len /= 2;
$pad_amount_left = floor($pad_len);
$pad_amount_right = ceil($pad_len);
$repeat_times_left = ceil($pad_amount_left / $pad_str_len);
$repeat_times_right = ceil($pad_amount_right / $pad_str_len);
$padding_left = sub(str_repeat($pad_str, $repeat_times_left), 0, $pad_amount_left);
$padding_right = sub(str_repeat($pad_str, $repeat_times_right), 0, $pad_amount_right);
return $padding_left . $input . $padding_right;
}
trigger_error('utf8_str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR);
}
示例3: sub_replace
/**
* UTF-8 aware substr_replace.
*
* @package php-utf-8
* @subpackage functions
* @see http://www.php.net/substr_replace
* @uses utf8_strlen
* @uses utf8_substr
*
* @param string $str
* @param string $repl
* @param int $start
* @param int $length
*
* @return string
*/
function sub_replace($str, $repl, $start, $length = null)
{
preg_match_all('/./us', $str, $ar);
preg_match_all('/./us', $repl, $rar);
$length = is_int($length) ? $length : len($str);
array_splice($ar[0], $start, $length, $rar[0]);
return implode($ar[0]);
}
示例4: add_row
function add_row($hook, $attributes)
{
$table .= "<tr><td><input type=\"button\" value=\"{$hook}\" onclick=\"pick({$hook})\"></td>";
for ($i = 0; $i < len($attributes); $i++) {
$table += "<td>" . $attributes[$i] . "</td>";
}
$table .= "</tr>";
}
示例5: split
/**
* UTF-8 aware alternative to str_split.
*
* Convert a string to an array
*
* @package php-utf-8
* @subpackage functions
* @see http://www.php.net/str_split
* @uses utf8_strlen
*
* @param string $str A UTF-8 encoded string
* @param int $split_len A number of characters to split string by
*
* @return string characters in string reverses
*/
function split($str, $split_len = 1)
{
if (!preg_match('/^[0-9]+$/', $split_len) || $split_len < 1) {
return false;
}
$len = len($str);
if ($len <= $split_len) {
return array($str);
}
preg_match_all('/.{' . $split_len . '}|[^\\x00]{1,' . $split_len . '}$/us', $str, $ar);
return $ar[0];
}
示例6: istxt
function istxt($str)
{
$i = 0;
$str1 = "";
while ($i < 4) {
$str1 .= $str[len($str) - $i];
}
if ($str1 != "txt.") {
return 0;
} else {
return 1;
}
}
示例7: cspn
/**
* UTF-8 aware alternative to strcspn.
*
* Find length of initial segment not matching mask.
*
* @package php-utf-8
* @subpackage functions
* @see http://www.php.net/strcspn
* @uses utf8_strlen
* @uses utf8_substr
*
* @param string $str
* @param string $mask
* @param integer $start
* @param integer $length
*
* @return integer|null
*/
function cspn($str, $mask, $start = null, $length = null)
{
if (empty($mask) || strlen($mask) == 0) {
return null;
}
$mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\\${1}', $mask);
if ($start !== null || $length !== null) {
$str = sub($str, $start, $length);
}
preg_match('/^[^' . $mask . ']+/u', $str, $matches);
if (isset($matches[0])) {
return len($matches[0]);
}
return 0;
}
示例8: wordwrap
/**
* UTF-8 aware alternative to wordwrap.
*
* Wraps a string to a given number of characters
* https://github.com/nicolas-grekas/Patchwork-UTF8
*
* @see http://www.php.net/manual/en/function.wordwrap.php
*
* @param string $str the input string
* @param int $width the column width
* @param string $break the line is broken using the optional break parameter
* @param boolean $cut
*
* @return string the given string wrapped at the specified column
*
* @package php-utf-8
* @subpackage functions
*/
function wordwrap($str, $width = 75, $break = "\n", $cut = false)
{
$width = (int) $width;
$str = explode($break, $str);
$i_len = count($str);
$result = array();
$line = '';
$line_len = 0;
for ($i = 0; $i < $i_len; ++$i) {
$words = explode(' ', $str[$i]);
$line && ($result[] = $line);
$line_len = len($line);
$jLen = count($words);
for ($j = 0; $j < $jLen; ++$j) {
$w = $words[$j];
$wLen = len($w);
if ($line_len + $wLen < $width) {
if ($j) {
$line .= ' ';
}
$line .= $w;
$line_len += $wLen + 1;
} else {
if ($j || $i) {
$result[] = $line;
}
$line = '';
$line_len = 0;
if ($cut && $wLen > $width) {
$w = split($w);
do {
$result[] = implode('', array_slice($w, 0, $width));
$line = implode('', $w = array_slice($w, $width));
$line_len = $wLen -= $width;
} while ($wLen > $width);
$w = implode('', $w);
}
$line = $w;
$line_len = $wLen;
}
}
}
$line && ($result[] = $line);
return implode($break, $result);
}
示例9: func_redir
function func_redir($line)
{
$tabtest = array();
preg_match("/([^>]*) >+ (.*)/", $line, $tabtest);
if (count($tabtest) != 3) {
echo "Syntax is wrong\n";
} else {
if (is_dir($tabtest[2]) || $tabtest[2][len($tabtest[2]) - 1] == '/') {
echo "content.php: {$tabtest[2]}: Is a directory\n";
} else {
if (file_exists($tabtest[2]) && !is_writable($tabtest[2])) {
echo "content.php: {$tabtest[2]}: Permission denied\n";
} else {
redirection($tabtest);
}
}
}
}
示例10: globalize
/**
* Global vars
*
* @param NCModule $module
* @param Theme $view
* @param Translate $lang
* @return array|\System\Engine\NCBlock[]
*/
static function globalize(NCModule $module, Theme $view, Translate $lang)
{
$view->twig->addFilter(new \Twig_SimpleFilter('ord', function ($order) {
$cur = Env::$request->get('order');
if (strpos($cur, $order) > -1) {
return $cur[0] == '-' ? 'fa-chevron-down' : 'fa-chevron-up';
}
return strpos($cur, $order);
}));
/**
* Substr
*/
$view->twig->addFilter(new \Twig_SimpleFilter('sub', function ($str, $len = 24) {
if (\len($str) > $len) {
$str = \cut($str, 0, $len - 3) . '...';
}
return $str;
}));
/**
* Long to ip
*/
$view->twig->addFilter(new \Twig_SimpleFilter('longip', function ($str) {
return long2ip($str);
}));
/**
* IP to long
*/
$view->twig->addFilter(new \Twig_SimpleFilter('iplong', function ($str) {
return ip2long($str);
}));
return ['title_prefix' => NCService::load('Application.Settings')->conf->get('title_prefix'), 'lang_code' => $lang->pack, 'ga' => lazy_arr('ga', ['$code' => function () {
/** @var GA $manager */
$manager = NCService::load('SocialMedia.GA');
return $manager->code();
}])];
}
示例11: getRParam
function getRParam($content, $lableStr)
{
$contentLCase = '';
$endS = '';
$i = '';
$s = '';
$c = '';
$isStart = '';
$startStr = '';
$isValue = '';
$content = ' ' . $content . ' ';
//避免更精准获得值
$contentLCase = lCase($content);
$lableStr = lCase($lableStr);
$endS = mid($content, inStr($contentLCase, $lableStr) + len($lableStr), -1);
//call echo("ends",ends)
$isStart = false;
//是否有开始类型值
$isValue = false;
//是否有值
for ($i = 1; $i <= len($endS); $i++) {
$s = mid($endS, $i, 1);
if ($isStart == true) {
if ($s != '') {
if ($startStr == '') {
$startStr = $s;
} else {
if ($startStr == '"' || $startStr == '\'') {
if ($s == $startStr) {
$isValue = true;
break;
}
} else {
if ($s == ' ' && $c == '') {
} else {
if ($s == ' ' || $s == '/' || $s == '>') {
$isValue = true;
break;
}
}
}
if ($s != ' ') {
$c = $c . $s;
}
}
}
}
if ($s == '=') {
$isStart = true;
}
}
if ($isValue == false) {
$c = '';
}
$getRParam = $c;
//call echo("c",c)
return @$getRParam;
}
示例12: JsEncode__
function JsEncode__($s)
{
if (isNul($s)) {
$JsEncode__ = '';
return @$JsEncode__;
}
$arr1 = '';
$arr2 = '';
$i = '';
$j = '';
$c = '';
$p = '';
$t = '';
$arr1 = array(chr(34), chr(92), chr(47), chr(8), chr(12), chr(10), chr(13), chr(9));
//34|",92|\,47|/,8|,12|,10| ,13| ,9| ,
$arr2 = array(chr(34), chr(92), chr(47), chr(98), chr(102), chr(110), chr(114));
//34|",92|\,47|/,98|b,102|f,110|n,114|r,1865|,
for ($i = 1; $i <= len($s); $i++) {
$p = true;
$c = mid($s, $i, 1);
for ($j = 0; $j <= uBound($arr1); $j++) {
if ($c == $arr1[$j]) {
$t = $t . '\\' . $arr2[$j];
$p = false;
break;
}
}
if ($p) {
$t = $t . $c;
}
}
$JsEncode__ = $t;
return @$JsEncode__;
}
示例13: count_attributes
//.........这里部分代码省略.........
}
//if code attribute exists
}
}
//Going to need a count of disbursements and of IF transactions
//Then need to test each against a set of criteria
/*if ($transaction_type == NULL) {
$transaction_type = "Missing";
echo "missing";
}
if ($transaction_type !="D") {
echo $id;
//die;
}*/
//Locations
//We can have more than one location, but they should add up to 100%
$locations = $activity->location;
//if (!isset($activities_with_location[$hierarchy])) {
// $activities_with_location[$hierarchy] = 0;
//}
if (isset($locations) && count($locations) > 0) {
$activities_with_location[$hierarchy][] = (string) $activity->{'iati-identifier'};
foreach ($locations as $location) {
if (isset($location->coordinates)) {
$activities_with_coordinates[$hierarchy][] = (string) $activity->{'iati-identifier'};
}
if (isset($location->administrative)) {
if (isset($location->administrative->attributes()->adm1)) {
$adm1 = string($location->administrative->attributes()->adm1);
}
if (isset($location->administrative->attributes()->adm2)) {
$adm2 = string($location->administrative->attributes()->adm2);
}
if (isset($adm1) && len($adm1) > 0 || isset($adm2) && len($adm2) > 0) {
$activities_with_adminstrative[$hierarchy][] = (string) $activity->{'iati-identifier'};
}
}
}
}
//Sector
$sectors = $activity->sector;
if (isset($sectors) && count($sectors) > 0) {
//$activities_with_sector[$hierarchy][] = (string)$activity->{'iati-identifier'};
foreach ($sectors as $sector) {
if (!isset($sector->attributes()->vocabulary)) {
$activities_sector_assumed_dac[$hierarchy][] = (string) $activity->{'iati-identifier'};
} elseif ((string) $sector->attributes()->vocabulary == "DAC") {
//echo "DAC";
$activities_sector_declared_dac[$hierarchy][] = (string) $activity->{'iati-identifier'};
}
}
}
//Last-updated-datetime
$last_updated = $activity->attributes()->{'last-updated-datetime'};
$last_updated = strtotime($last_updated);
if (!isset($most_recent[$hierarchy])) {
$most_recent[$hierarchy] = 0;
}
if ($last_updated > $most_recent[$hierarchy]) {
$most_recent[$hierarchy] = $last_updated;
}
//Activity dates
$activity_dates = $activity->{"activity-date"};
//if (count($activity_dates) > 0) {
//if ($activity_dates !=NULL) {
// $activities_with_at_least_one[$hierarchy]++;
示例14: formatting
function formatting($content, $action)
{
$i = '';
$endStr = '';
$s = '';
$c = '';
$labelName = '';
$startLabel = '';
$endLabel = '';
$endLabelStr = '';
$nLevel = '';
$isYes = '';
$parentLableName = '';
$nextLableName = '';
//下一个标题名称
$isA = '';
//是否为A链接
$isTextarea = '';
//是否为多行输入文本框
$isScript = '';
//脚本语言
$isStyle = '';
//Css层叠样式表
$isPre = '';
//是否为pre
$startLabel = '<';
$endLabel = '>';
$nLevel = 0;
$action = '|' . $action . '|';
//层级
$isA = false;
$isTextarea = false;
$isScript = false;
$isStyle = false;
$isPre = false;
$content = replace(replace($content, vbCrlf(), chr(10)), vbTab(), ' ');
for ($i = 1; $i <= len($content); $i++) {
$s = mid($content, $i, 1);
$endStr = mid($content, $i, -1);
if ($s == '<') {
if (inStr($endStr, '>') > 0) {
$s = mid($endStr, 1, inStr($endStr, '>'));
$i = $i + len($s) - 1;
$s = mid($s, 2, len($s) - 2);
if (right($s, 1) == '/') {
$s = PHPTrim(left($s, len($s) - 1));
}
$endStr = right($endStr, len($endStr) - len($s) - 2);
//最后字符减去当前标签 -2是因为它有<>二个字符
//注意之前放在labelName下面
$labelName = mid($s, 1, inStr($s . ' ', ' ') - 1);
$labelName = lCase($labelName);
//call echo("labelName",labelName)
if ($labelName == 'a') {
$isA = true;
} else {
if ($labelName == '/a') {
$isA = false;
} else {
if ($labelName == 'textarea') {
$isTextarea = true;
} else {
if ($labelName == '/textarea') {
$isTextarea = false;
} else {
if ($labelName == 'script') {
$isScript = true;
} else {
if ($labelName == '/script') {
$isScript = false;
} else {
if ($labelName == 'style') {
$isStyle = true;
} else {
if ($labelName == '/style') {
$isStyle = false;
} else {
if ($labelName == 'pre') {
$isPre = true;
} else {
if ($labelName == '/pre') {
$isPre = false;
}
}
}
}
}
}
}
}
}
}
$endLabelStr = $endLabel;
$nextLableName = getHtmlLableName($endStr, 0);
//不为压缩HTML
if (inStr($action, '|ziphtml|') == false && $isPre == false) {
if ($isA == false) {
if (inStr('|a|strong|u|i|s|script|', '|' . $labelName . '|') == false && '/' . $labelName != $nextLableName && inStr('|/a|/strong|/u|/i|/s|/script|', '|' . $nextLableName . '|') == false) {
$endLabelStr = $endLabelStr . chr(10);
}
//.........这里部分代码省略.........
示例15: webStat
function webStat($folderPath)
{
$dateTime = '';
$content = '';
$splStr = '';
$thisUrl = '';
$goToUrl = '';
$caiShu = '';
$c = '';
$fileName = '';
$co = '';
$ie = '';
$xp = '';
$goToUrl = serverVariables('HTTP_REFERER');
$thisUrl = 'http://' . serverVariables('HTTP_HOST') . serverVariables('SCRIPT_NAME');
$caiShu = serverVariables('QUERY_STRING');
if ($caiShu != '') {
$thisUrl = $thisUrl . '?' . $caiShu;
}
$goToUrl = @$_REQUEST['GoToUrl'];
$thisUrl = @$_REQUEST['ThisUrl'];
$co = @$_GET['co'];
$dateTime = now();
$content = serverVariables('HTTP_USER_AGENT');
$content = replace($content, 'MSIE', 'Internet Explorer');
$content = replace($content, 'NT 5.0', '2000');
$content = replace($content, 'NT 5.1', 'XP');
$content = replace($content, 'NT 5.2', '2003');
$splStr = aspSplit($content . ';;;;', ';');
$ie = $splStr[1];
$xp = aspTrim($splStr[2]);
if (right($xp, 1) == ')') {
$xp = mid($xp, 1, len($xp) - 1);
}
$c = '来访' . $goToUrl . vbCrlf();
$c = $c . '当前:' . $thisUrl . vbCrlf();
$c = $c . '时间:' . $dateTime . vbCrlf();
$c = $c . 'IP:' . getIP() . vbCrlf();
$c = $c . 'IE:' . getBrType('') . vbCrlf();
$c = $c . 'Cookies=' . $co . vbCrlf();
$c = $c . 'XP=' . $xp . vbCrlf();
$c = $c . 'Screen=' . @$_REQUEST['screen'] . vbCrlf();
//屏幕分辨率
$c = $c . '用户信息=' . serverVariables('HTTP_USER_AGENT') . vbCrlf();
//用户信息
$c = $c . '-------------------------------------------------' . vbCrlf();
//c=c & "CaiShu=" & CaiShu & vbcrlf
$fileName = $folderPath . Format_Time(now(), 2) . '.txt';
CreateAddFile($fileName, $c);
$c = $c . vbCrlf() . $fileName;
$c = replace($c, vbCrlf(), '\\n');
$c = replace($c, '"', '\\"');
//Response.Write("eval(""var MyWebStat=\""" & C & "\"""")")
$splxx = '';
$nIP = '';
$nPV = '';
$ipList = '';
$s = '';
$ip = '';
//判断是否显示回显记录
if (@$_REQUEST['stype'] == 'display') {
$content = getFText($fileName);
$splxx = aspSplit($content, vbCrlf() . '-------------------------------------------------' . vbCrlf());
$nIP = 0;
$nPV = 0;
$ipList = '';
foreach ($splxx as $key => $s) {
if (inStr($s, '当前:') > 0) {
$s = vbCrlf() . $s . vbCrlf();
$ip = ADSql(getStrCut($s, vbCrlf() . 'IP:', vbCrlf(), 0));
$nPV = $nPV + 1;
if (inStr(vbCrlf() . $ipList . vbCrlf(), vbCrlf() . $ip . vbCrlf()) == false) {
$ipList = $ipList . $ip . vbCrlf();
$nIP = $nIP + 1;
}
}
}
Rw('document.write(\'网长统计 | 今日IP[' . $nIP . '] | 今日PV[' . $nPV . '] \')');
}
$webStat = $c;
return @$webStat;
}