php substr(),explode(),strrev()_PHP教程

WBOY
풀어 주다: 2016-07-20 11:02:33
원래의
1210명이 탐색했습니다.

 

substr(str,start,length); 

例:substr('php教程 is very good language',4,5);

输出为 is ve;

当start>str的长度,则返回为();

substr('php is very good language',26,5);

substr('php is very good language',4);

输出为        (空白)

输出为is v     (表明start和langth都为4)

当start为负值,则从str末尾出开始读起(*这时是从-1开始读,而不是从0开始),

substr('php is very good language',-4,5);

输出为uage

当length为负值时,length代表的是从末尾开始读,截取str的结束位置。

substr('php is very good language',4,-5);

输出为is very good lan

explode()把函数字符串分割为数组;

// example 1
$pizza  = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2

// example 2
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
echo $gecos."
"; // foo
echo $shell; // *

strrev()把字符串从后往前输出

echo strrev("june"); // outputs "enuj"

setlocalhost(content location)设置本地环境.content ,指定需要设置的场景信息常量有(

lc_all – 所有下属的常量
lc_collate – 排列顺序
lc_ctype – 字符分类和转换(例如:将所有的字符转换成小写或大写形式)
lc_messages – 系统信息格式
lc_monetary – 货币 / 通货格式
lc_numeric – 数值格式
lc_time – 日期和时间格式
);location,设置国家区域,例如,chs.


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445364.htmlTechArticlesubstr(str,start,length); 例:substr(php教程 is very good language,4,5); 输出为 is ve; 当startstr的长度,则返回为(); substr(php is very good language,26,5); s...
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!