字符串操作函数
函数|字符串
PHP3.0中的字符串操作功能是比较多的,重要的有以下这些:
(1)echo,print,printf,sprintf
用于输出字符串.字符串中如果有变量名则被替换成其值. 后两个函数类似于C的同名函数.
(2)strchr, strlen, strtok, strrchr, strrev, strstr, strtolower, strtoupper, substr, ucfirst
用的字符串操作函数,有些和C中的同名函数意义完全一致. strrev是把一个字符串翻转. strtolower和strtoupper是将字符串转换为小写和大写.ucfirst是把字符串的第一个字符变成大写. substr是返回字符串的一个子串,用法是:substr(字符串,头,长度).头位置是从0算起的.如果是负数,则是从尾部向前数的意思.
(3)Chr,Ord
同名函数.
(4)explode,implode,join
与数组有关的函数. explode(字符串,分割符)返回一个将字符串在分割符处分开所产生的数组. implode(数组,分割符)返回一个将数组各元素之间插上分割符而成的字符串. join与implode意义相同.
(5)Chop
处理串尾部的空白.
(6)htmlspecialchars
将HTML特殊字符换成它们的名字,例如"
(7)nl2br
在HTML中的每一个回车前面加上"
".
(8)AddSlashes,StripSlashes
给字符串中按照需要加上"\"和去掉"\",对于某些数据库,必须在要查询的字符加上和去掉"\"之后才能够查询.
(9)parse_str
将"name1=value1&name2=value2&..."类型的字符串分析成一些变量.
例如: parse_str("a=1&b=2"); 生成$a与$b两个变量,值分别为1,2. 如果有两对名字/值的名字部分相同,则后一个的值覆盖前一个的. 如果这两对的名字尾部都有"[]",例如"a[]=1&a[]=2",则生成数组$a,两个元素分别为1,2.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In PHP, we often need to combine elements in an array into a string. At this time, the implode() function comes in handy. The implode() function converts the elements in the array into strings and concatenates them to produce a complete string. This article will introduce how to use the implode() function in PHP to convert an array into a string. 1. Basic usage of implode() function The implode() function has two parameters. The first parameter

Convert a string to lowercase using PHP function "strtolower" In PHP, there are many functions that can be used to convert the case of a string. One of the very commonly used functions is strtolower(). This function converts all characters in a string to lowercase. Here is a simple example code showing how to use the strtolower() function to convert a string to lowercase: <?php//original string $string="

In PHP programming, Warning messages often appear. One of the more common prompts is "PHPWarning:implode():Invalidargumentspassed". This article will introduce the ideas and methods to solve this Warning. First, we need to understand how to use the implode() function. The function of this function is to concatenate an array into a string, using the following syntax: string

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

In PHP programming, processing strings is a frequently required operation. Among them, splitting and merging strings are two common requirements. In order to perform these operations more conveniently, PHP provides two very practical functions, namely the explode and implode functions. This article will introduce the usage of these two functions, as well as some practical skills. 1. The explode function The explode function is used to split a string according to the specified delimiter and return an array. Its function prototype is as follows: arra

This article will explain in detail the ASCII value of the first character of the string returned by PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can gain something after reading this article. PHP returns the ASCII value of the first character of a string Introduction In PHP, getting the ASCII value of the first character of a string is a common operation that involves basic knowledge of string processing and character encoding. ASCII values are used to represent the numeric value of characters in computer systems and are critical for character comparison, data transmission and storage. The process of getting the ASCII value of the first character of a string involves the following steps: Get String: Determine the string for which you want to get the ASCII value. It can be a variable or a string constant

This article will explain in detail how PHP returns the string from the start position to the end position of a string in another string. The editor thinks it is quite practical, so I share it with you as a reference. I hope you will finish reading this article. You can gain something from this article. Use the substr() function in PHP to extract substrings from a string. The substr() function can extract characters within a specified range from a string. The syntax is as follows: substr(string,start,length) where: string: the original string from which the substring is to be extracted. start: The index of the starting position of the substring (starting from 0). length (optional): The length of the substring. If not specified, then

In PHP programming, the implode function is a very commonly used function that can concatenate elements in an array into a string. Using this function can save developers from writing a lot of code to connect strings, making it more efficient. The basic syntax of implode is: stringimplode(string$glue,array$pieces). This function receives two parameters: $glue represents the separator to connect the array elements, and $pieces represents
