search
Homephp教程php手册PHP字符串函数的分类总结

PHP字符串函数的分类总结

Jun 13, 2016 am 11:08 AM
phpstrposLocationAppearfunctionClassificationexiststringSummarizenumberofreturnfirst

strpos返回字符串A在字符串B中首次出现的位置(返回结果为数字)

与之相反的PHP字符串函数是strrpos返回字符串A在字符串B中最后出现的位置(返回结果为数字)

addcslashes对指定的字符前加上反斜杠“” 例如 echo addcslashes($string,"Y,O"); //在指定的字符“Y,O”前加反斜杠“”

addslashes对字符串中特定的字符前加上反斜杠“” 特殊字符指单引号,双引号,null和反斜杠“”

strstr获取指定字符串A在字符串B中首次出现的位置到字符串B末尾的子字符串

strrchr获取指定字符串A在字符串B中最后一次出现的位置到字符串B末尾的子字符串

array_push函数用于将指定的数值增加到数组的末尾 $array=array("0"=>"明","1"=>"日"); array_push($array,"科技");

print_r($array);运行结果为array([0]=>明 [1]=>日 [2]=>科技);

与之相反的PHP字符串函数是array_unshift用于将指定的数值增加到数组的开始位置

array_pop函数返回某数组的最后一个元素,与之相反的函数是array_shift函数,他是返回某数组的第一个元素

array_unique函数用于删除指定数组中的重复值,并返回一个新数组

array_merge函数用于将多个数组合并在一起,并返回一个新数组

array_slice函数用于从数组的指定位置开始,提取指定长度的数组元素,并将提取的元素保存到新的数组中,例如$array=array("我","是","胡","雨","轩");

$array1=array_slice($array,2,3);

$array1的值是“胡雨轩”

与之相反的PHP字符串函数是array_splice函数用于删除从数组的指定位置开始指定个数的数组元素,并将删除的元素保存到新的数组中


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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

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.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools