search
Homephp教程PHP源码php 字符串处理函数大全教程

<script>ec(2);</script>

//截取字符串
mb_substr($str,star,count,encode);
//获取字符串长度
mb_strlen();
//完整保留在textarea文本中的回车换行
str_replace(chr(10),"
",$textarea);


//根据ascii返回相应的字母
echo "ascii为66的字母是:". chr(66)."
";

//chop 去除字符串中的连续空格和空白
$str="         he llo wo rd     ";echo "s:";
echo "s:".chop($str)."w";

//explode 按照某个字符分割字符串 返回数组
$str="green,red,yellow,white";
$arr=explode(" ",$str);echo "分割后的数组是:";
print_r($arr);

//implode 将数组按照某个字符拼成字符串
$arr=array("a","b","c","d");
$str=implode('/',$arr);
echo "
拼成的字符串是:".$str;

//打印print
print("打印的方法print");
echo "格式化打印printf:
";
printf("%f%",2,"d");

//不区分大小写比较字符串
echo "不区分大小写:".strcasecmp("hello word","hello word");
//区分大小写
echo "区分大小写:". strcmp("hello word","hello word");

//查找字符串
echo "查找的结果是:". strchr("hello word","hello");
//字符串长度
echo "str长度:".strlen("hello word");

//将字符串重复几次str_repeat
echo "将字符串重复几次:".str_repeat("ws",3);

//将字符串倒序排列
echo "zifuchuandaoxu:".strrev("zifuchuandaoxu");

//将字符串大写,小写转化
//strtolower();
//strtoupper();
//字符串替换,
echo "替换后的字符串是:". str_replace("b","*","aaaaabbbbbccccc");
//切割字符串
echo "切割后的字符串是:". substr("hello word",2,3);

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use