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


PHP SUBSTR函数代码示例

本文整理汇总了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;
}
开发者ID:Pandafuchs,项目名称:codingame,代码行数:28,代码来源:invertHexColor.php

示例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;
}
开发者ID:utilo-web-app-development,项目名称:REZERVI,代码行数:27,代码来源:benutzerFunctions.inc.php

示例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;
}
开发者ID:katstar01,项目名称:fivebeers,代码行数:36,代码来源:alphabet.php

示例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;
 }
开发者ID:lautarodragan,项目名称:ideary,代码行数:7,代码来源:alltags.php

示例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;
}
开发者ID:ideagital,项目名称:how2doo.com,代码行数:9,代码来源:functions_date.php

示例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);
 }
开发者ID:JasonDarkX2,项目名称:Wordpress-WidgetManager,代码行数:52,代码来源:settings.php

示例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, ",", ".");
}
开发者ID:AvnerGeraldo,项目名称:TCC-SIRP,代码行数:13,代码来源:funcoes_helper.php

示例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;
    }
}
开发者ID:skymak2050,项目名称:Schol2,代码行数:23,代码来源:day_of_week.php

示例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;
 }
开发者ID:rickyx12,项目名称:mendero,代码行数:24,代码来源:myDatabase_04252014.php

示例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");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:hilmysyarif,项目名称:hotel-application-laravel,代码行数:31,代码来源:doAddAboutUs.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;
 }
开发者ID:BigBoss424,项目名称:boyer,代码行数:11,代码来源:bigcalendarmonth.php

示例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"]);
开发者ID:kractos26,项目名称:orfeo,代码行数:31,代码来源:cuerpo.php

示例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-->
开发者ID:jabiralhaiyan,项目名称:simbat,代码行数:31,代码来源:view_pesan.php

示例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("~", "`", "!", "@", "#", "\$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", "}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;", "—", "–", ",", "<", ".", ">", "/", "?");
    $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;
}
开发者ID:yanguanglan,项目名称:themoviedb-webfrontend,代码行数:31,代码来源:functions.php

示例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);
 }
开发者ID:hackdracko,项目名称:belcorp,代码行数:27,代码来源:Tramite.php


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