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

PHP length函数代码示例

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

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



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

示例1: widget

 function widget($args, $n = '')
 {
     // $args is an array of strings that help widgets to conform to
     // the active theme: before_widget, before_title, after_widget,
     // and after_title are the array keys. Default tags: li and h2.
     extract($args);
     //nb. $name comes out of this, hence the use of $n
     global $advman_engine;
     //If name not passed in (Sidebar Modules), extract from the widget-id (WordPress Widgets)
     if ($n == '') {
         $l = length(__('Ad: '));
         $n = substr($args['widget_name'], $l);
         //Chop off beginning advman- bit
     }
     if ($n == 'default-ad') {
         $n = $advman_engine->getSetting('default-ad');
     }
     $ad = $advman_engine->selectAd($n);
     if (!empty($ad)) {
         $widgets = $advman_engine->getSetting('widgets');
         $id = substr(md5($ad->name), 0, 10);
         $suppress = !empty($widgets[$id]['suppress']);
         $ad_widget = '';
         $ad_widget .= $suppress ? '' : $before_widget;
         if (!empty($widgets[$id]['title'])) {
             $ad_widget .= $suppress ? '' : $before_title;
             $ad_widget .= $widgets[$id]['title'];
             $ad_widget .= $suppress ? '' : $after_title;
         }
         $ad_widget .= $ad->display();
         //Output the selected ad
         $ad_widget .= $suppress ? '' : $after_widget;
         echo $ad_widget;
     }
 }
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:35,代码来源:Widget_Old.php


示例2: truncate

 public static function truncate($subject, $length, $omission = '...')
 {
     if (length($subject) > $length) {
         $omission_length = length($omission);
         $subject = substr($subject, 0, length($subject) - $omission_length);
         $subject .= $omission;
     }
     return $subject;
 }
开发者ID:ale88andr,项目名称:Nova,代码行数:9,代码来源:String.php


示例3: ends_with

/**
 * Determine if a given string ends with a given substring.
 *
 * @param string       $haystack
 * @param string|array $needles
 *
 * @return bool
 */
function ends_with(string $haystack, $needles) : bool
{
    foreach ((array) $needles as $needle) {
        if ((string) $needle === substr($haystack, -length($needle))) {
            return true;
        }
    }
    return false;
}
开发者ID:spatie,项目名称:ssl-certificate,代码行数:17,代码来源:helpers.php


示例4: length

/**
 * Returns the number of elements in a list.
 *
 * @param Cons $alist a list
 */
function length($alist)
{
    if (isNull($alist)) {
        return 0;
    } elseif (isPair($alist)) {
        return 1 + length(cdr($alist));
    } else {
        throw new \InvalidArgumentException("{$alist} is not a proper list");
    }
}
开发者ID:mudge,项目名称:php-microkanren,代码行数:15,代码来源:Lisp.php


示例5: wfSpecialGeo

/**
 *
 */
function wfSpecialGeo($page = '')
{
    global $wgOut, $wgLang, $wgRequest;
    $coordinates = htmlspecialchars($wgRequest->getText('coordinates'));
    $coordinates = explode(":", $coordinates);
    $ns = array_shift($coordinates);
    $ew = array_shift($coordinates);
    if (0 < count($coordinates)) {
        $zoom = length(array_shift($coordinates));
    } else {
        $zoom = 6;
    }
    $ns = explode(".", $ns);
    $ew = explode(".", $ew);
    while (count($ns) < 3) {
        $ns[] = "0";
    }
    while (count($ew) < 3) {
        $ew[] = "0";
    }
    $mapquest = "http://www.mapquest.com/maps/map.adp?latlongtype=decimal&latitude={$ns[0]}.{$ns[1]}&longitude={$ew[0]}.{$ew[1]}&zoom={$zoom}";
    $mapquest = "<a href=\"{$mapquest}\">Mapquest</a>";
    $wgOut->addHTML("{$mapquest}");
    /*	
    	if( $wgRequest->getVal( 'action' ) == 'submit') {
    		$page = $wgRequest->getText( 'pages' );
    		$curonly = $wgRequest->getCheck( 'curonly' );
    	} else {
    		# Pre-check the 'current version only' box in the UI
    		$curonly = true;
    	}
    	
    	if( $page != "" ) {
    		header( "Content-type: application/xml; charset=utf-8" );
    		$pages = explode( "\n", $page );
    		$xml = pages2xml( $pages, $curonly );
    		echo $xml;
    		wfAbruptExit();
    	}
    	
    	$wgOut->addWikiText( wfMsg( "exporttext" ) );
    	$titleObj = Title::makeTitle( NS_SPECIAL, "Export" );
    	$action = $titleObj->escapeLocalURL();
    	$wgOut->addHTML( "
    <form method='post' action=\"$action\">
    <input type='hidden' name='action' value='submit' />
    <textarea name='pages' cols='40' rows='10'></textarea><br />
    <label><input type='checkbox' name='curonly' value='true' checked='checked' />
    " . wfMsg( "exportcuronly" ) . "</label><br />
    <input type='submit' />
    </form>
    " );
    */
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:57,代码来源:SpecialGeo.php


示例6: Perla_strlen

function Perla_strlen($text) {
    if (isset($text)) {
        return length($text);
    }
    else
    {
        return 'Podaj ciąg mający więcej niż 0 znaków!';
    }
    echo Perla_reverse('perła');
    //test
}
开发者ID:sparrow41,项目名称:training,代码行数:11,代码来源:Ex_first.php


示例7: getParentCategory

 public function getParentCategory($category_id)
 {
     if (length($category_id) < 2) {
         throw Dolcore_Exception(sprintf(_('Tried to get the parent category of a top category %s'), $category_id));
     }
     $parent_id = substr($category_id, 0, -1);
     $parent = $this->getCategory($parent_id);
     if (!$parent) {
         throw Dolcore_Exception(sprintf(_('No parent category for child category %s'), $category_id));
     }
     return $parent;
 }
开发者ID:ralflang,项目名称:dolcore,代码行数:12,代码来源:Category.php


示例8: readbtable

function readbtable($tfile, $genelist, $numgenes)
{
    $f = fopen($tfile, "rb");
    $out = array();
    for ($i = 0; $i < length($genelist); $i++) {
        fseek($f, $genelist[$i] * $numgenes - 1);
        #from start???
        $out[] = fread($f, $numgenes);
        #double somehow
    }
    fclose($f);
    return $out;
}
开发者ID:mahogny,项目名称:esexpress,代码行数:13,代码来源:common.php


示例9: addItem

 public function addItem($vars = array())
 {
     $cnf = Zend_Registry::get('cnf');
     $db = Zend_Db::factory($cnf->db);
     $cols = "";
     $values = "";
     foreach ($vars as $key => $value) {
         $coma = length($cols) > 0 ? "," : "";
         $cols += $coma + "`{$key}\\`";
         $values += $coma + "\\'{$value}\\'";
     }
     $db->query("INSERT admin_menu ({$cols}) VALUES ({$values})");
 }
开发者ID:albertobraschi,项目名称:zstarter,代码行数:13,代码来源:AdminstructModel.php


示例10: checkLastConsonantSoftness

 public function checkLastConsonantSoftness($word)
 {
     if (($substring = last_position_for_one_of_chars(lower($word), array_map(__NAMESPACE__ . '\\lower', self::$consonants))) !== false) {
         if (in_array(slice($substring, 0, 1), ['й', 'ч', 'щ'])) {
             // always soft consonants
             return true;
         } else {
             if (length($substring) > 1 && in_array(slice($substring, 1, 2), ['е', 'ё', 'и', 'ю', 'я', 'ь'])) {
                 // consonants are soft if they are trailed with these vowels
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:wapmorgan,项目名称:morphos,代码行数:15,代码来源:Russian.php


示例11: substr

 public static function substr($str, $startPos, $length = 0)
 {
     if ($startPos < 0) {
         $startPos = length($str) + $startPos;
         if ($startPos < 0) {
             $startPos = length($str);
         }
     }
     preg_match_all("/./u", $str, $array);
     if ($length) {
         $end = $startPos + $length;
         return join("", array_slice($array[0], $start, $end));
     } else {
         return join("", array_slice($array[0], $start));
     }
 }
开发者ID:piotrPiechura,项目名称:3dPathProject,代码行数:16,代码来源:CoreUtils.class.php


示例12: do

 public function do($searchData, $cleanWord)
 {
     if (length($cleanWord) > length($searchData)) {
         throw new LogicException('[Cleaner::data()] -> 3.($cleanWord) parameter not be longer than 2.($searchData) parameter!');
     }
     if (!is_array($searchData)) {
         $result = str_replace($cleanWord, '', $searchData);
     } else {
         if (!is_array($cleanWord)) {
             $cleanWordArray[] = $cleanWord;
         } else {
             $cleanWordArray = $cleanWord;
         }
         $result = array_diff($searchData, $cleanWordArray);
     }
     return $result;
 }
开发者ID:znframework,项目名称:znframework,代码行数:17,代码来源:Data.php


示例13: url_upload

 function url_upload($url)
 {
     if ($img_type = $this->check_img_url($url)) {
         $content = $this->down_with_curl($url);
     } else {
         $this->err_msg .= ' !URL изображения не верен ';
         return FALSE;
     }
     if ($content == false && length($content) < 100) {
         $this->err_msg .= ' !Изображение не загруженно ';
         return FALSE;
     }
     $img_fname = md5($content) . '.' . $img_type;
     file_put_contents($this->img_folder . $img_fname, $content);
     $this->file_data = array('file_name' => $img_fname, 'file_path' => $this->img_folder);
     return TRUE;
 }
开发者ID:skybee,项目名称:cctv-pro,代码行数:17,代码来源:Upload_img_lib.php


示例14: traerCapacitacionMenu

function traerCapacitacionMenu()
{
    $db = Conectar();
    $sql = "SELECT * FROM capacitacion ORDER BY id_cap DESC";
    $resultado = $db->query($sql);
    while ($data = $resultado->fetch_object()) {
        echo '

		<article class="CursosImagenes col" >
      	<h2><a class="LinkCursos" href="curso_detalle.php?id=' . $data->id_cap . '#aqui" >' . length($data->titulo) . '</a></h2>
      
      	<a href="curso_detalle.php?id=' . $data->id_cap . '#aqui" rel="nofollow" >   
        <div class="ImagenCurso"><img class="SacarSeccionCelular" src="upload/' . $data->imagen . '"/><div class="HoverCursos"><div class="SimboloMas"></div></div></div>
      	</a>
    	</article>
    	';
    }
    return $resultado;
}
开发者ID:EzequielDot175,项目名称:muysimple,代码行数:19,代码来源:capacitacion_menu.inc15-6-15.php


示例15: replaceAll

 /**
  * Replaces all old string within the expression with new strings.
  *
  * @param String|\Tbm\Peval\Types\String $expression
  *            The string being processed.
  * @param String|\Tbm\Peval\Types\String $oldString
  *            The string to replace.
  * @param String|\Tbm\Peval\Types\String $newString
  *            The string to replace the old string with.
  *
  * @return mixed The new expression with all of the old strings replaced with new
  *         strings.
  */
 public function replaceAll(string $expression, string $oldString, string $newString)
 {
     $replacedExpression = $expression;
     if ($replacedExpression != null) {
         $charCtr = 0;
         $oldStringIndex = $replacedExpression->indexOf($oldString, $charCtr);
         while ($oldStringIndex > -1) {
             // Remove the old string from the expression.
             $buffer = new StringBuffer($replacedExpression->subString(0, oldStringIndex)->getValue() . $replacedExpression->substring($oldStringIndex + $oldString . length()));
             // Insert the new string into the expression.
             $buffer . insert($oldStringIndex, $newString);
             $replacedExpression = buffer . toString();
             $charCtr = $oldStringIndex + $newString->length();
             // Determine if we need to continue to search.
             if ($charCtr < $replacedExpression->length()) {
                 $oldStringIndex = $replacedExpression->indexOf($oldString, $charCtr);
             } else {
                 $oldStringIndex = -1;
             }
         }
     }
     return $replacedExpression;
 }
开发者ID:ghooning,项目名称:peval,代码行数:36,代码来源:EvaluationHelper.php


示例16: actionCreate

 public function actionCreate()
 {
     $model = new Parametro();
     if (isset($_POST['Parametro'])) {
         $model->setAttributes($_POST['Parametro']);
         if (length($model->ValorFecha) > 0) {
             $model->ValorFecha = date('Y-m-d', CDateTimeParser::parse($model->ValorFecha, Yii::app()->locale->dateFormat));
         }
         try {
             if ($model->save()) {
                 if (isset($_GET['returnUrl'])) {
                     $this->redirect($_GET['returnUrl']);
                 } else {
                     $this->redirect(array('view', 'id' => $model->idParametro));
                 }
             }
         } catch (Exception $e) {
             $model->addError('', $e->getMessage());
         }
     } elseif (isset($_GET['Parametro'])) {
         $model->attributes = $_GET['Parametro'];
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:juankie,项目名称:gestcb9git,代码行数:24,代码来源:ParametroController.php


示例17: fopen

<?php

$a = fopen('raha.txt', 'w');
fwrite($a, 'my name is raha');
fread($a, length($a));
开发者ID:Rahajustone,项目名称:PHP,代码行数:5,代码来源:creatforlder.php


示例18: add_user

/**
 * Adds user to the database
 *
 * Registration function, this controls the sign up functionality.
 * @global array
 * @global resource
 * @param string $username username of user being added
 * @param string $password password of user being added
 * @param string $password_again password again to be checked against first $password
 * @param string $email email incase email registration is turned on
 * @param string $age mm/dd/yyyy
 * @return string|boolean
 */
function add_user($username, $password, $password_again, $email, $age = false)
{
    global $config, $database;
    // 904	- Registration complete, needs to validate email!
    // Check Username
    if (!alpha($username, 'alpha-underscore')) {
        return lang_parse('error_invalid_chars', array(lang('username')));
    }
    // Username Taken
    if (username_check($username)) {
        return lang('error_username_taken');
    }
    // Check Username Length
    $length = length($username, $config['min_name_length'], $config['max_name_length']);
    if ($length) {
        if ($length == "TOO_LONG") {
            return lang('error_username_too_long');
        } else {
            return lang('error_username_too_short');
        }
    }
    // Check Password Length
    $length = length($password, $config['min_name_length'], $config['max_name_length']);
    if ($length) {
        if ($length == "TOO_LONG") {
            return lang('error_password_too_long');
        } else {
            return lang('error_password_too_short');
        }
    }
    // Setup Passwords
    if ($password == $password_again) {
        $raw_pass = $password;
        $password = md5($password);
    } else {
        return lang('error_password_match');
    }
    // Check email
    if (!is_email($email)) {
        return lang_parse('error_invalid_given', array(lang('email')));
    }
    // Banned?
    $query = "SELECT * FROM `users` WHERE `email` = '{$email}' AND `banned` = '1' LIMIT 1";
    $result = $database->query($query);
    if ($database->num($result) > 0) {
        return lang('error_banned_email');
    }
    // Exist?
    $query = "SELECT * FROM `users` WHERE `email` = '{$email}' LIMIT 1";
    $result = $database->query($query);
    // Email exists
    if ($database->num($result) > 0) {
        return lang('error_email_used');
    }
    // Do we have to validate age?
    if ($config['age_validation']) {
        if ($age) {
            // Start grabbing age data~
            $age_data = explode('/', $age);
            if (alpha($age_data[2], 'numeric')) {
                if (strlen($age_data[2]) < 4) {
                    return lang('error_year_invalid');
                }
                $old_enough = age_limit($age_data[2], $config['age_validation']);
                if (!$old_enough) {
                    return lang_parse('error_year_young', array($config['age_validation']));
                }
            } else {
                return lang_parse('error_given_not_numeric', array(lang('year_c')));
            }
        } else {
            return lang('error_year_invalid');
        }
    }
    load_hook('add_user_check');
    // Finally Add user
    if ($config['email_validation']) {
        // The Key for Validation
        $key = md5($username . $email . substr(microtime(), 1, 3));
        // The query
        $query = "INSERT INTO `users` (`username`,`password`,`email`,`join_date`,`age`,`active`,`key`) VALUES ('{$username}', '{$password}', '{$email}', '" . time() . "','{$age}','0','{$key}')";
    } else {
        // The query
        $query = "INSERT INTO `users` (`username`,`password`,`email`,`join_date`,`age`,`active`) VALUES ('{$username}', '{$password}', '{$email}', '" . time() . "','{$age}','1')";
    }
    // Return Data
    if ($result = $database->query($query)) {
//.........这里部分代码省略.........
开发者ID:nijikokun,项目名称:NinkoBB,代码行数:101,代码来源:user.php


示例19: update

/**
 * Allows updating of topics, stuck or closed, and posts
 * @global array
 * @global array
 * @global resource
 * @param integer $id post we are editing
 * @param string $topic post subject
 * @param string $content post content
 * @param integer $reply id of topic we are replying to
 * @param boolean $sticky are we sticking it to the top?
 * @param boolean $closed are we closing it?
 * @return string|int
 */
function update($id, $category, $topic, $content, $sticky = false, $closed = false)
{
    global $config, $user_data, $database;
    // The time. milliseconds / seconds may change.
    $time = time();
    // Is the id numeric?
    if (!alpha($id, 'numeric')) {
        return lang_parse('error_given_not_numeric', array(lang('post') . " " . lang('id')));
    }
    // Grab the data for the update.
    $post_data = topic($id);
    // Check to see if the post or topic was found.
    if (!$post_data) {
        return lang('error_post_missing');
    }
    // Pre-Parse
    $topic = strip_repeat($topic);
    // Can't update a replies category!
    if ($post_data['reply']) {
        $category = $post_data['category'];
    }
    // Check validity of category as numeric
    if (!alpha($category, 'numeric')) {
        return lang('error_invalid_category');
    }
    // Check to see if category exists
    $category = category($category);
    if (!$category) {
        return lang('error_invalid_category');
    }
    // Check category settings against user
    if (!$user_data['admin']) {
        if ($category['aop'] && $post_data['reply']) {
            if (!$user_data['admin'] || !$user_data['moderator']) {
                return lang('error_invalid_category');
            }
        }
        if ($category['aot'] && !$post_data['reply']) {
            if ($user_data['id'] != $category['aot']) {
                return lang('error_invalid_category');
            }
        }
    }
    // Is the user currently logged in? If not we can't update return error.
    if ($_SESSION['logged_in']) {
        // Editing a topic not post
        if ($post_data['reply'] == 0) {
            // Is there a topic?
            if ($topic == "") {
                return lang_parse('error_no_given', array(lang('username')));
            }
        } else {
            // If there was no topic put re: on it.
            if ($topic == "") {
                $topic = "re:";
            }
        }
        // Is the subject valid?
        if (!alpha($topic, 'alpha-extra')) {
            return lang_parse('error_invalid_chars', array(lang('subject')));
        }
        // Did they give us any content to work with?
        if ($content != "") {
            if (!is_string(length($content, $config['message_minimum_length'], $config['message_max_length']))) {
                // Check to see if the user is an admin and able to sticky / close the topic
                if ($_SESSION['admin'] || $_SESSION['moderator']) {
                    // Sticky
                    $sticky = $sticky ? '1' : '0';
                    // Closed
                    $closed = $closed ? '1' : '0';
                    // Admin functions
                    update_field($id, 'sticky', $sticky);
                    update_field($id, 'closed', $closed);
                }
                // Parsing
                $topic = $database->escape($topic);
                $content = $database->escape($content);
                // Update the post already inside of the database with the new data
                $result = $database->query("UPDATE `forum` SET `category`='{$category['id']}', `subject`='{$topic}', `message`='{$content}', `updated`='{$time}', `replies`='{$replies}' WHERE id = '{$id}'") or die(mysql_error());
                // Did it work?
                if ($result) {
                    // Update replies with category
                    if ($category != $post_data['category'] && !$post_data['reply']) {
                        $database->query("UPDATE `forum` SET `category`='{$category['id']}' WHERE `reply` = {$id}");
                    }
                    return true;
                } else {
//.........这里部分代码省略.........
开发者ID:nijikokun,项目名称:NinkoBB,代码行数:101,代码来源:forum.php


示例20: getSidFromURI

 private function getSidFromURI($url, $cookieName)
 {
     $sid = "";
     if ($url != null) {
         //			if (debug . messageEnabled()) {
         //				debug . message("getSidFromURI: url=" + url);
         //			}
         if ($url != null && length($url) > 0) {
             $start = strpos($url, $cookieName);
             if ($start) {
                 $start = $start + length($cookieName) + 1;
                 $end = strpos($url, SessionEncodeURL::QUERY, $start);
                 if ($end) {
                     $sid = substr($url, $start, $end - 1);
                 } else {
                     $sid = substr($url, $start);
                 }
             }
         }
     }
     //		if (debug . messageEnabled()) {
     //			debug . message("getSidFromURL: sid =" + sid);
     //		}
     return $sid;
 }
开发者ID:GajendraNaidu,项目名称:openam,代码行数:25,代码来源:SessionEncodeURL.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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