本文整理汇总了PHP中SUBSTR函数的典型用法代码示例。如果您正苦于以下问题:PHP SUBSTR函数的具体用法?PHP SUBSTR怎么用?PHP SUBSTR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SUBSTR函数的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: fivebeers_aznav
/**
* List letters A-Z Based on posts in the database
*/
function fivebeers_aznav()
{
$num = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
$alphabet = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
global $wpdb;
$myposts = $wpdb->get_results("SELECT post_title FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_title");
$n[] = '';
foreach ($myposts as $mypost) {
$n[] = strtoupper(SUBSTR(trim($mypost->post_title), 0, 1));
}
$output = '<div id="aznav"><div class="nav-links azindex">';
//$output = '<div id="aznav"><div class="nav-links azindex">';
for ($i = 0; $i < count($num); $i++) {
if (in_array($num[$i], $n)) {
$number = true;
break;
}
}
if (isset($number)) {
$output .= '<a href="#" class="alphabet azindex" rel="num">0-9</a>';
} else {
$output .= '<span class="alphabet current">0-9</span>';
}
for ($i = 0; $i < count($alphabet); $i++) {
if (in_array($alphabet[$i], $n)) {
$output .= '<a href="#" class="alphabet azindex" rel="' . $alphabet[$i] . '">' . $alphabet[$i] . '</a>';
} else {
$output .= '<span class="alphabet current">' . $alphabet[$i] . '</span>';
}
}
$output .= '</div><div style="clear:both"></div>';
echo $output;
}
示例4: getImageColor
private function getImageColor($params)
{
$transparency = intval($params->get('wordleTransparency', 127));
$backgroundColor = $params->get('wordleBackgroundColor', '000000');
$imageColor = array(HEXDEC(SUBSTR($backgroundColor, 0, 2)), HEXDEC(SUBSTR($backgroundColor, 2, 2)), HEXDEC(SUBSTR($backgroundColor, 4, 2)), $transparency);
return $imageColor;
}
示例5: convertdate
function convertdate($datadate)
{
$month = array('มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม');
$day = SUBSTR($datadate, 8, 2);
$mon = SUBSTR($datadate, 5, 2);
$year = SUBSTR($datadate, 0, 4);
$mix = $day . ' ' . $month[$mon - 1] . ' ' . $year;
return $mix;
}
示例6: changeWidgetDir
function changeWidgetDir($newDir)
{
$defaultDir = str_replace('//', '/', str_replace('\\', '/', dirname(plugin_dir_path(__FILE__)))) . '/custom-widgets/';
if (empty($newDir) || get_option('preset-cdwd') == TRUE || get_option('widgetdir') == '/') {
$newDir = $defaultDir;
$dirchange = TRUE;
}
$newDir = str_replace('//', '/', str_replace('\\', '/', $newDir));
$wpdir = str_replace('//', '/', str_replace('\\', '/', wp_upload_dir()));
$plugindir = str_replace('//', '/', str_replace('\\', '/', dirname(plugin_dir_path(__FILE__))));
if (WPWM_DEBUG == 1) {
$error = TRUE;
$errmsg = "Debug Mode enabled, unrestricted directory changes permitted";
} else {
if (strstr($newDir, $plugindir) == FALSE) {
$error = TRUE;
$errmsg = " ERROR-Custom Widget Directory must be within Wordpress manager plugin directory. The default had been set instead of " . $newDir . '<br/>';
$newDir = dirname(plugin_dir_path(__FILE__)) . '/custom-widgets/';
$dirchange = TRUE;
}
}
$dirchange = TRUE;
$newDir = str_replace('//', '/', str_replace('\\', '/', $newDir));
if (file_exists($newDir) == FALSE) {
$dirDiff = true;
mkdir($newDir, 0755);
$user = exec(whoami);
chown($newDir, $user);
}
$sourceDir = get_option('widgetdir');
if (file_exists($sourceDir)) {
$sourceDir = str_replace('//', '/', str_replace('\\', '/', $sourceDir));
if (strcmp($sourceDir, $wpdir['basedir']) != 0) {
$contents = scandir($sourceDir);
if (SUBSTR($newDir, -1) != '/') {
$newDir .= '/';
}
foreach ($contents as $widgets) {
if ($widgets != "." && $widgets != "..") {
recurse_copy($sourceDir, $newDir);
}
}
if ($sourceDir != $newDir) {
if ($sourceDir != $defaultDir) {
$check = recursiveRemove($sourceDir);
}
}
}
}
update_option('widgetdir', $newDir);
msgDisplay($error, $errmsg, $dirchange, $dirDiff);
}
示例7: formataValorExibir
function formataValorExibir($valor)
{
$valor = formataValorBanco($valor);
$arrayValor = explode(".", $valor);
if (isset($arrayValor[1])) {
$arrayValor[1] = SUBSTR($arrayValor[1], 0, 2);
$valor = $arrayValor[0] . "." . $arrayValor[1];
}
if (strpos($valor, ".") > 0 && strpos($valor, ",") > 0) {
$valor = str_replace(",", ".", str_replace(".", "", $valor));
}
return number_format($valor, 2, ",", ".");
}
示例8: DayOfWeek
function DayOfWeek($d, $short = False)
{
if ($d == 1) {
$day = "Monday";
} elseif ($d == 2) {
$day = "Tuesday";
} elseif ($d == 3) {
$day = "Wednesday";
} elseif ($d == 4) {
$day = "Thursday";
} elseif ($d == 5) {
$day = "Friday";
} elseif ($d == 6) {
$day = "Saturday";
} elseif ($d == 7) {
$day = "Sunday";
}
if ($short) {
return SUBSTR($day, 0, 3);
} else {
return $day;
}
}
示例9: 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;
}
示例10: header
} else {
if ($mision == "") {
header("location:addAboutUs.php?errorMsg=Mision must be filled!");
} else {
if ($web == "") {
header("location:addAboutUs.php?errorMsg=Link Web must be filled!");
} else {
if ($book == "") {
header("location:addAboutUs.php?errorMsg=Link Book must be filled!");
} else {
$count = mysql_query("SELECT ID_Aboutus as 'Flag' FROM aboutus ORDER BY ID_Aboutus DESC LIMIT 1") or die(mysql_error());
$temp;
while ($row = mysql_fetch_array($count)) {
$temp = $row[0];
}
if (SUBSTR(strval($temp), 3, -5) == strval(date("y"))) {
mysql_query("INSERT INTO aboutus VALUES (\n\t\t\tCONCAT('ABT', SUBSTRING(YEAR(CURRENT_TIMESTAMP),3,2), \n\t\t\tLPAD((SUBSTR((SELECT au.ID_Aboutus FROM aboutus au ORDER BY au.ID_Aboutus DESC LIMIT 1),6) + 1 ), 5, 0)),\n\t\t\t'" . $name . "','" . $address . "','" . $telp . "','" . $email . "','" . $about . "','" . $concept . "','" . $vision . "','" . $mision . "','" . $web . "','" . $book . "'");
} else {
mysql_query("INSERT INTO aboutus VALUES (\n\t\t\tCONCAT('ABT', SUBSTRING(YEAR(CURRENT_TIMESTAMP),3,2), '00001'),\n\t\t\t'" . $name . "','" . $address . "','" . $telp . "','" . $email . "','" . $about . "','" . $concept . "','" . $vision . "','" . $mision . "','" . $web . "','" . $book . "'");
}
header("location:aboutus.php");
}
}
}
}
}
}
}
}
}
}
示例11: style
function style($title, $color)
{
$new_title = html_entity_decode(strip_tags($title));
$number = $new_title[0];
$first_letter = $new_title[1];
$ev_title = $title;
$color = str_replace('#', '', $color);
$bg_color = 'rgba(' . HEXDEC(SUBSTR($color, 0, 2)) . ',' . HEXDEC(SUBSTR($color, 2, 2)) . ',' . HEXDEC(SUBSTR($color, 4, 2)) . ',0.3' . ')';
$event = '<div id="cal_event" style="background-color:' . $bg_color . ' !important;border-left:2px solid #' . $color . ' "><p>' . $ev_title . '</p></div>';
return $event;
}
示例12: ora_parse
$numerop = 0;
$numeroh = 0;
echo "<center>DocuImage - WEB <BR> CONTROL DOCUMENTOS DE CORRESPONDENCIA</center>";
echo "<table border=1 width=100%>";
echo "<td width=55%>";
echo "<br>";
$isql = "select USUA_LOGIN,USUA_PASW from usuario where USUA_LOGIN ='{$krd}'";
$resultado = ora_parse($cursor, $isql);
$resultado = ora_exec($cursor);
$row = array();
ora_fetch_into($cursor, $row, ORA_FETCHINTO_NULLS | ORA_FETCHINTO_ASSOC);
//echo $row["usuario"].$krd;
echo "<font size=1>Usuario " . $row["USUA_LOGIN"] . "<br>";
if (trim($row["USUA_LOGIN"]) == trim($krd)) {
$contraxx = $row["USUA_PASW"];
if (trim($contraxx) == SUBSTR(md5(trim($drd)), 1, 26)) {
$iusuario = " and us_usuario='{$krd}'";
$isql = "select * from radicado where carp_codi={$carpeta}";
echo $isql;
//$isql ="select * from radicado_rd where rd_estado=5 $iusuario ";
// $result1 = ora_do($handle,$isql);
ora_parse($cursor, $isql);
ora_exec($cursor);
$numerot = ora_numrows($cursor);
$row = array();
echo "<table border=1>";
while ($result1 = ora_fetch_into($cursor, $row, ORA_FETCHINTO_NULLS | ORA_FETCHINTO_ASSOC)) {
$row1 = array();
//$data = trim(ora_getcolumn($cursor, 1));
$data = trim($row["RADI_NUME_RADI"]);
$numdata = trim($row["CARP_CODI"]);
示例13: foreach
<th>Waktu</th>
<th>Aksi</th>
</tr>
</thead>
<?php
foreach ($kotakkeluar->result() as $row) {
?>
<tbody>
<tr>
<th><?php
echo $row->Penerima;
?>
</th>
<td><?php
echo SUBSTR($row->Pesan, 0, 20) . '...';
?>
</td>
<th><?php
echo $row->Waktu;
?>
</th>
<td>
<a type="button" class="btn btn-primary btn-xs" data-toggle="modal" href=".bs-example-modal-lg<?php
echo $row->IdPesan;
?>
"><i class="fa fa-folder"></i> View</a>
<!--Modal-->
示例14: session_start
<?php
session_start();
$page = SUBSTR(strrchr($_SERVER["REQUEST_URI"], '/'), 1);
if ($page != "install.php" && !file_exists(dirname(__FILE__) . '/config.php')) {
header("location: install.php");
die;
}
function timer($runtime)
{
$hours = floor($runtime / 60);
// No. of mins/60 to get the hours and round down
$mins = $runtime % 60;
// No. of mins/60 - remainder (modulus) is the minutes
return $hours . " hrs " . $mins . " mins";
}
function isloggedin()
{
return isset($_SESSION['tmdb_username']);
}
function updatesite($db_name, $db_host, $db_username, $db_password)
{
}
function sanitize($string, $force_lowercase = true, $anal = true)
{
$strip = array("~", "`", "!", "@", "#", "\$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", "}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—", "—", "–", ",", "<", ".", ">", "/", "?");
$clean = trim(str_replace($strip, "", strip_tags($string)));
$clean = preg_replace('/\\s+/', "-", $clean);
$clean = $anal ? preg_replace("/[^a-zA-Z0-9]/", "-", $clean) : $clean;
return $force_lowercase ? function_exists('mb_strtolower') ? mb_strtolower($clean, 'UTF-8') : strtolower($clean) : $clean;
}
示例15: 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);
}