本文整理汇总了PHP中STRLEN函数的典型用法代码示例。如果您正苦于以下问题:PHP STRLEN函数的具体用法?PHP STRLEN怎么用?PHP STRLEN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STRLEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: inverseHex
function inverseHex($color)
{
$color = TRIM($color);
$prependHash = FALSE;
if (STRPOS($color, '#') !== FALSE) {
$prependHash = TRUE;
$color = STR_REPLACE('#', NULL, $color);
}
switch ($len = STRLEN($color)) {
case 3:
$color = PREG_REPLACE("/(.)(.)(.)/", "\\1\\1\\2\\2\\3\\3", $color);
case 6:
break;
default:
TRIGGER_ERROR("Invalid hex length ({$len}). Must be (3) or (6)", E_USER_ERROR);
}
if (!PREG_MATCH('/[a-f0-9]{6}/i', $color)) {
$color = HTMLENTITIES($color);
TRIGGER_ERROR("Invalid hex string #{$color}", E_USER_ERROR);
}
$r = DECHEX(255 - HEXDEC(SUBSTR($color, 0, 2)));
$r = STRLEN($r) > 1 ? $r : '0' . $r;
$g = DECHEX(255 - HEXDEC(SUBSTR($color, 2, 2)));
$g = STRLEN($g) > 1 ? $g : '0' . $g;
$b = DECHEX(255 - HEXDEC(SUBSTR($color, 4, 2)));
$b = STRLEN($b) > 1 ? $b : '0' . $b;
return ($prependHash ? '#' : NULL) . $r . $g . $b;
}
示例2: ENCRYPT_DECRYPT
function ENCRYPT_DECRYPT($Str_Message)
{
//Function : encrypt/decrypt a string message v.1.0 without a known key
//Author : Aitor Solozabal Merino (spain)
//Email : aitor-3@euskalnet.net
//Date : 01-04-2005
$Len_Str_Message = STRLEN($Str_Message);
$Str_Encrypted_Message = "";
for ($Position = 0; $Position < $Len_Str_Message; $Position++) {
// long code of the function to explain the algoritm
//this function can be tailored by the programmer modifyng the formula
//to calculate the key to use for every character in the string.
$Key_To_Use = $Len_Str_Message + $Position + 1;
// (+5 or *3 or ^2)
//after that we need a module division because can´t be greater than 255
$Key_To_Use = (255 + $Key_To_Use) % 255;
$Byte_To_Be_Encrypted = SUBSTR($Str_Message, $Position, 1);
$Ascii_Num_Byte_To_Encrypt = ORD($Byte_To_Be_Encrypted);
$Xored_Byte = $Ascii_Num_Byte_To_Encrypt ^ $Key_To_Use;
//xor operation
$Encrypted_Byte = CHR($Xored_Byte);
$Str_Encrypted_Message .= $Encrypted_Byte;
//short code of the function once explained
//$str_encrypted_message .= chr((ord(substr($str_message, $position, 1))) ^ ((255+(($len_str_message+$position)+1)) % 255));
}
return $Str_Encrypted_Message;
}
示例3: FUNCDEF_OVERRIDE
function FUNCDEF_OVERRIDE($MATCHES)
{
$this->RECORD($MATCHES[0], 'KEYWORD');
$this->POS_SHIFT(STRLEN($MATCHES[0]));
$this->skip_whitespace();
if ($this->SCAN('/[a-z_]\\w*/i')) {
$this->RECORD($this->MATCH(), 'USER_FUNCTION');
$this->user_defs[$this->MATCH()] = 'FUNCTION';
}
}
示例4: funcdefOverride
public function funcdefOverride($MATCHES)
{
$this->RECORD($MATCHES[0], 'KEYWORD');
$this->POSSHIFT(STRLEN($MATCHES[0]));
$this->SKIPWHITESPACE();
if ($this->SCAN('/[a-z_]\\w*/i')) {
$this->RECORD($this->MATCH(), 'USER_FUNCTION');
$this->userDefs[$this->MATCH()] = 'FUNCTION';
}
}
示例5: PHONE
public static function PHONE($N)
{
$N = PREG_REPLACE("/[^0-9]/", "", $N);
if (STRLEN($N) == 7) {
return PREG_REPLACE("/([0-9]{3})([0-9]{4})/", "\$1-\$2", $N);
} else {
if (STRLEN($N) == 10) {
return PREG_REPLACE("/([0-9]{3})([0-9]{3})([0-9]{4})/", "(\$1) \$2-\$3", $N);
} else {
return $N;
}
}
}
示例6: output
public function output(Pagemill_Data $data, Pagemill_Stream $stream)
{
$data = $data->fork();
if (!empty($this->attributes['menuplugid'])) {
$menuplugid = $this->attributes['menuplugid'];
$db = Typeframe::Database();
$base = substr(Typeframe::CurrentPage()->uri(), STRLEN(TYPEF_WEB_DIR));
if ($base == '') {
$base = '/';
}
$search = new Model_Nav();
$search->where('plugid = ?', $menuplugid);
$search->where('url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR pageid = ?', "~{$base}", "~{$base}/", "/{$base}", "/{$base}/", TYPEF_WEB_DIR . $base, TYPEF_WEB_DIR . $base . '/', Typeframe::CurrentPage()->pageid());
foreach ($search->select() as $current) {
$current['url'] = $this->_convertUrl($current['url']);
$data->set('current', $current);
$parentid = $current['parent'];
$siblings = new Model_Nav();
$siblings->where('plugid = ?', $menuplugid);
$siblings->where('parent = ?', $parentid);
$siblings->order('sortnum');
$data['siblings'] = $siblings;
/*$sibArray = array();
foreach ($siblings->select() as $sib) {
$sib['url'] = $this->_convertUrl($sib['url']);
$sibArray[] = $sib;
}
$data['siblings'] = $sibArray;*/
if (!empty($this->attributes['showparent'])) {
$parent = $db->execute('SELECT * FROM #__nav WHERE itemid = ' . $parentid);
foreach ($parent as $par) {
$par['url'] = $this->_convertUrl($par['url']);
$data->set('parent', $par);
}
}
if (!empty($this->attributes['showchildren'])) {
$childArray = array();
$children = $db->execute('SELECT * FROM #__nav WHERE plugid = ' . $menuplugid . ' AND parent = ' . $current['itemid'] . ' ORDER BY sortnum');
foreach ($children as $chi) {
$chi['url'] = $this->_convertUrl($chi['url']);
$childArray[] = $chi;
}
$data['children'] = $childArray;
}
}
}
$this->pluginTemplate = "navigation/submenu.plug.html";
parent::output($data, $stream);
}
示例7: MySQLDateToSeconds
function MySQLDateToSeconds($dt)
{
$tempdate = split('[- :]', $dt);
$year = $tempdate[0];
$month = $tempdate[1];
$daynum = $tempdate[2];
if (STRLEN($dt) < 19) {
$hour = "00";
$minute = "00";
$second = "00";
} else {
$hour = $tempdate[3];
$minute = $tempdate[4];
$second = $tempdate[5];
}
return mktime($hour, $minute, $second, $month, $daynum, $year);
}
示例8: ENCRYPT_DECRYPT
function ENCRYPT_DECRYPT($Str_Message)
{
$Len_Str_Message = STRLEN($Str_Message);
$Str_Encrypted_Message = "";
for ($Position = 0; $Position < $Len_Str_Message; $Position++) {
// long code of the function to explain the algoritm
//this function can be tailored by the programmer modifyng the formula
//to calculate the key to use for every character in the string.
$Key_To_Use = ($Len_Str_Message + $Position) * 230;
// (+5 or *3 or ^2)
//after that we need a module division because can´t be greater than 255
//$Key_To_Use = (255+$Key_To_Use) % 255;
$Key_To_Use = (168 + $Key_To_Use) % 168;
$Byte_To_Be_Encrypted = SUBSTR($Str_Message, $Position, 1);
$Ascii_Num_Byte_To_Encrypt = ORD($Byte_To_Be_Encrypted);
$Xored_Byte = $Ascii_Num_Byte_To_Encrypt ^ $Key_To_Use;
//xor operation
$Encrypted_Byte = CHR($Xored_Byte);
$Str_Encrypted_Message .= $Encrypted_Byte;
//short code of the function once explained
//$str_encrypted_message .= chr((ord(substr($str_message, $position, 1))) ^ ((255+(($len_str_message+$position)+1)) % 255));
}
return $Str_Encrypted_Message;
}
示例9: Modifica_Autorizaciones
public function Modifica_Autorizaciones($t_id, $autorizador, $lugar)
{
$query = "SELECT t_ruta_autorizacion FROM tramites WHERE t_id = {$t_id}";
$rst = parent::consultar($query);
$aux = explode("|", mysql_result($rst, 0, 't_ruta_autorizacion'));
$t_autorizaciones = "";
for ($i = 0; $i < count($aux); $i++) {
if ($lugar == 0) {
if ($lugar == $i) {
$t_autorizaciones .= $autorizador;
break;
} else {
$t_autorizaciones .= $aux[$i];
}
} else {
if ($lugar == $i) {
$t_autorizaciones .= "|" . $autorizador;
break;
} else {
$t_autorizaciones .= "|" . $aux[$i];
}
}
}
$t_autorizaciones = SUBSTR($t_autorizaciones, 0, 1) == "|" ? SUBSTR($t_autorizaciones, 1, STRLEN($t_autorizaciones)) : $t_autorizaciones;
$query = "UPDATE tramites SET t_autorizaciones = '{$t_autorizaciones}', t_fecha_ultima_modificacion = NOW() WHERE t_id='{$t_id}'";
parent::insertar($query);
}
示例10: cut
/**
* Short description.
*/
public function cut($str, $from, $to, $direct = 'out')
{
//echo "$str n $from n $to n";
//$from = """; $to = """;
$frompos = STRPOS($str, $from);
$topos = STRPOS($str, $to, $frompos + STRLEN($from));
if ($direct == 'in') {
$start = $frompos + STRLEN($from);
$end = $topos - $start;
$txt = SUBSTR($str, $start, $end);
} else {
$start = $frompos;
$end = $topos + STRLEN($to) - $frompos;
$txt = SUBSTR($str, $start, $end);
}
return $txt;
}
示例11: getTimeDiff
function getTimeDiff($dtime, $atime)
{
$dtime = substr($dtime, 0, 5);
$atime = substr($atime, 0, 5);
$nextDay = $dtime > $atime ? 1 : 0;
$dep = EXPLODE(':', $dtime);
$arr = EXPLODE(':', $atime);
$diff = ABS(MKTIME($dep[0], $dep[1], 0, DATE('n'), DATE('j'), DATE('y')) - MKTIME($arr[0], $arr[1], 0, DATE('n'), DATE('j') + $nextDay, DATE('y')));
$hours = FLOOR($diff / (60 * 60));
$mins = FLOOR(($diff - $hours * 60 * 60) / 60);
$secs = FLOOR($diff - ($hours * 60 * 60 + $mins * 60));
if (STRLEN($hours) < 2) {
$hours = "0" . $hours;
}
if (STRLEN($mins) < 2) {
$mins = "0" . $mins;
}
if (STRLEN($secs) < 2) {
$secs = "0" . $secs;
}
return $hours . ':' . $mins . ':' . $secs;
}
示例12: shuffle
}
shuffle($wyniki);
if (count($wyniki) > 0) {
$i = 0;
foreach ($wyniki as $r) {
if ($i < 8) {
$i++;
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
$color = '#' . $rand[rand(0, 15)] . $rand[rand(0, 15)] . $rand[rand(0, 15)] . $rand[rand(0, 15)] . $rand[rand(0, 15)] . $rand[rand(0, 15)];
$hashlesscolor = STR_REPLACE('#', NULL, $color);
$rr = DECHEX(255 - HEXDEC(SUBSTR($hashlesscolor, 0, 2)));
$rr = STRLEN($rr) > 1 ? $rr : '0' . $rr;
$gg = DECHEX(255 - HEXDEC(SUBSTR($hashlesscolor, 2, 2)));
$gg = STRLEN($gg) > 1 ? $gg : '0' . $gg;
$bb = DECHEX(255 - HEXDEC(SUBSTR($hashlesscolor, 4, 2)));
$bb = STRLEN($bb) > 1 ? $bb : '0' . $bb;
$invcolor = '#' . $rr . $gg . $bb;
echo "<div class=\"col-md-3 col-centered\"style=\"text-align:center;padding: 2.5% 2.5% 2.5% 2.5%;\">";
echo "<div class=\"circle\" style=\"text-shadow: -1px 0 #444444, 0 1px #444444, 1px 0 #444444, 0 -1px #444444; border: 1px solid black;color:" . $invcolor . "; background-color:" . $color . "\">";
echo "<a href=\"sesja.php?sesja=" . $r['id_sesji'] . "\">";
echo "<h2>" . $r['lokalizacja'] . "</h2>";
echo "<p>" . $r['data'] . "</p>";
echo "</a>";
echo "</div>";
echo "</div>";
} else {
break;
}
}
} else {
echo '<p style="text-align:center;">Aktualnie w systemie nie ma żadnych dodanych przez fotografów sesji zdjęciowych.</p>';
示例13: fetchOngoingProjects
function fetchOngoingProjects($id)
{
try {
global $dbh;
$query = $dbh->prepare('SELECT projectID as `pid`,
projectName as `pn`,
duedate as `dd`,
FLOOR(totalNumHours/60) as `h`,
MOD(totalNumHours, 60) as `m`
FROM project
WHERE draftsmanID = :id
AND status = "ongoing"');
$query->bindParam(':id', $id);
$query->execute();
while ($row = $query->fetch()) {
if (STRLEN($row['m']) > 2) {
$row['m'] = substr($row['m'], 0, 2);
}
$d = date("F d, Y", strtotime($row['dd']));
echo "<tr>";
echo "<td>" . $row['pn'] . "</td>";
echo "<td>" . $d . "</td>";
echo "<td>" . $row['h'] . " hours and " . $row['m'] . " minutes</td>";
echo '<td><a href="viewLogs2.php?pid=' . $row['pid'] . '"><button class="btn btn-info btn-sm" style="width:100%;" type="submit"><span class="glyphicon glyphicon-stats"></span> View Logs</button></a></td>';
echo "</tr>";
}
} catch (PDOException $ex) {
}
}
示例14: getHourDiff
function getHourDiff($firstHour, $secondHour)
{
$dtime = substr($firstHour, 0, 5);
$atime = substr($secondHour, 0, 5);
$nextDay = $dtime > $atime ? 1 : 0;
$dep = EXPLODE(':', $dtime);
$arr = EXPLODE(':', $atime);
$diff = ABS(MKTIME($dep[0], $dep[1], 0, DATE('n'), DATE('j'), DATE('y')) - MKTIME($arr[0], $arr[1], 0, DATE('n'), DATE('j') + $nextDay, DATE('y')));
$hours = FLOOR($diff / (60 * 60));
$mins = FLOOR(($diff - $hours * 60 * 60) / 60);
$secs = FLOOR($diff - ($hours * 60 * 60 + $mins * 60));
if (STRLEN($hours) < 2) {
$hours = "0" . $hours;
}
if (STRLEN($mins) < 2) {
$mins = "0" . $mins;
}
if (STRLEN($secs) < 2) {
$secs = "0" . $secs;
}
$temp = floatval($mins / 60);
$temp += $hours;
return $temp;
}
示例15: controllerPaginas
<?php
require_once "controllerPaginas.php";
$cPaginas = new controllerPaginas();
$conteudo_pagina = null;
$requisicao_pagina = STR_REPLACE(".php", "", empty($_SERVER['REQUEST_URI']) ? 'index' : SUBSTR($_SERVER['REQUEST_URI'], 1, STRLEN($_SERVER['REQUEST_URI'])));
if (strpos($requisicao_pagina, "/") >= 0) {
$arrayRequisicao = explode("/", $requisicao_pagina);
$requisicao_pagina = empty($arrayRequisicao[1]) ? 'index' : $arrayRequisicao[1];
}
$arrayPaginas = $cPaginas->listaPaginas();
foreach ($arrayPaginas as $pagina) {
if ($pagina['link_pagina'] == strtolower($requisicao_pagina)) {
$conteudo_pagina = $pagina['conteudo_pagina'];
}
}
/*
if( empty($conteudo_pagina) ) {
echo "<script type='text/javascript'>window.location.href='error-page.html';</script>";
exit;
}
*/
?>
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="web-files/lib/bootstrap/dist/css/bootstrap.min.css" media="all">
<link rel="stylesheet" href="web-files/css/themes/bootstrap.min.css" media="all">
<link rel="stylesheet" href="web-files/css/styleWebsite.css" media="all">