Blogger Information
Blog 47
fans 1
comment 0
visits 40598
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
实例演示字符串函数
新手1314
Original
427 people have browsed it

strrev(): 颠倒字符串。

  1. $str = 'php.cn';
  2. echo strrev($str);
  3. //输出结果:nc.php

ucfirst(): 将字符串第一个字符改大写。

  1. $str = 'php.cn';
  2. echo ucfirst($str);
  3. //输出结果:Php.cn

chunk_split() 函数把字符串分割为一连串更小的部分。

  1. $str = 'php.cn';
  2. echo chunk_split($str,1,' ');
  3. //输出结果:p h p . c n

strchr():搜索字符串在另一字符串中的第一次出现。

  1. echo strchr("i study php in php.cn!","in");
  2. //输出结果:in php.cn!
  3. echo strchr("i study php in php.cn!","in"true);
  4. //输出结果:i study php

strtoupper():字符串全转为大写。

  1. $str = 'php.cn';
  2. echo strtoupper($str);
  3. //输出结果:PHP.CN

strtr():函数转换字符串中特定的字符(或子字符串)

  1. echo strtr('Hello wstan','stan','orld');
  2. //输出结果:Hello world
  3. $arr = array("Hello" => "Hello", "world" => "php.cn");
  4. echo strtr("Hello world",$arr);
  5. //输出结果:Hello php.cn

ucwords: 将字符串每个字第一个字母改大写

  1. $strs = 'hello world welcome to php.cn';
  2. echo ucwords($strs);
  3. //输出结果:Hello World Welcome To Php.cn

nl2br():字符串中的每个新行(\n)之前插入 HTML 换行符

  1. $str = "Hello\nWorld";
  2. echo nl2br($str,false);
  3. //输出结果:Hello
  4. World
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post