PHP 字符串函數(shù)
PHP提供了各種字符串函數(shù)來訪問和操作字符串。愛掏網(wǎng) - it200.com
下面是一些PHP字符串函數(shù)的列表。愛掏網(wǎng) - it200.com
addcslashes() | 它用于返回一個帶有反斜杠的字符串。愛掏網(wǎng) - it200.com |
---|---|
addslashes() | 它用于返回一個帶有反斜杠的字符串。愛掏網(wǎng) - it200.com |
bin2hex() | 它用于將ASCII字符的字符串轉(zhuǎn)換為十六進(jìn)制值。愛掏網(wǎng) - it200.com |
chop() | 它從字符串的右端刪除空格或其他字符。愛掏網(wǎng) - it200.com |
chr() | 它用于根據(jù)指定的ASCII值返回一個字符。愛掏網(wǎng) - it200.com |
chunk_split() | 它用于將字符串分割成一系列較小的部分。愛掏網(wǎng) - it200.com |
convert_cyr_string() | 用于將一個字符串從一個Cyrillic字符集轉(zhuǎn)換為另一個。愛掏網(wǎng) - it200.com |
convert_uudecode() | 用于解碼一個uuencoded字符串。愛掏網(wǎng) - it200.com |
convert_uuencode() | 用于使用uuencode算法對字符串進(jìn)行編碼。愛掏網(wǎng) - it200.com |
count_chars() | 用于返回字符串中使用的字符的信息。愛掏網(wǎng) - it200.com |
crc32() | 用于計算字符串的32位CRC。愛掏網(wǎng) - it200.com |
crypt() | 用于創(chuàng)建單向哈希字符串。愛掏網(wǎng) - it200.com |
echo() | 用于輸出一個或多個字符串。愛掏網(wǎng) - it200.com |
htmlentities() | 用于將字符串轉(zhuǎn)換為 HTML 實體字符。愛掏網(wǎng) - it200.com |
html_entity_decode() | 用于將HTML實體轉(zhuǎn)換為字符。愛掏網(wǎng) - it200.com |
htmlspecialchars() | 將特殊字符轉(zhuǎn)換為HTML實體。愛掏網(wǎng) - it200.com |
htmlspecialchars_decode() | 將HTML實體轉(zhuǎn)換回特殊字符。愛掏網(wǎng) - it200.com |
implode() | 用于從數(shù)組的元素返回一個字符串。愛掏網(wǎng) - it200.com |
join() | implode()函數(shù)的別名。愛掏網(wǎng) - it200.com |
Levenshtein() | 用于返回兩個字符串之間的Levenshtein距離。愛掏網(wǎng) - it200.com |
Lcfirst() | 它用于將字符串的第一個字符轉(zhuǎn)換為小寫。愛掏網(wǎng) - it200.com |
localeconv() | 獲取數(shù)值格式化信息 |
ltrim() | 它用于刪除字符串左側(cè)的空格。愛掏網(wǎng) - it200.com |
md5() | 它用于計算字符串的MD5哈希值。愛掏網(wǎng) - it200.com |
md5_files() | 它用于計算文件的MD5哈希值。愛掏網(wǎng) - it200.com |
metaphone() | 它用于計算字符串的metaphone鍵。愛掏網(wǎng) - it200.com |
money_format() | 它用于返回格式化為貨幣字符串的字符串。愛掏網(wǎng) - it200.com |
nl2br() | 用于在字符串中的每個換行符前插入HTML換行符。愛掏網(wǎng) - it200.com |
nl_langinfo() | 查詢語言和區(qū)域設(shè)置信息。愛掏網(wǎng) - it200.com |
number_format() | 用于按組分隔格式化數(shù)字。愛掏網(wǎng) - it200.com |
ord() | 用于返回字符串的第一個字符的ASCII值。愛掏網(wǎng) - it200.com |
parse_str() | 用于解析查詢字符串為變量。愛掏網(wǎng) - it200.com |
print() | 用于輸出一個或多個字符串。愛掏網(wǎng) - it200.com |
printf() | 用于將輸出顯示為格式化的字符串。愛掏網(wǎng) - it200.com |
quoted_printable_decode() | 將quoted-printable字符串轉(zhuǎn)換為8位字符串 |
quoted_printable_encode() | 將8位字符串轉(zhuǎn)換回quoted-printable字符串 |
quotemeta() | 引用元字符 |
rtrim() | 用于從字符串右側(cè)刪除空白 |
setlocale() | 用于設(shè)置區(qū)域設(shè)置信息 |
sha1() | 用于返回字符串的SHA-1哈希值 |
sha1_file() | 用于返回文件的SHA-1哈希值 |
similar_text() | 比較兩個字符串的相似度。愛掏網(wǎng) - it200.com |
Soundex() | 計算字符串的Soundex鍵值。愛掏網(wǎng) - it200.com |
sprintf() | 返回格式化的字符串。愛掏網(wǎng) - it200.com |
sscanf() | 根據(jù)格式從字符串中解析輸入。愛掏網(wǎng) - it200.com |
strcasecmp() | 比較兩個字符串,不區(qū)分大小寫。愛掏網(wǎng) - it200.com |
strchr() | 在一個字符串中查找另一個字符串的第一次出現(xiàn)。愛掏網(wǎng) - it200.com |
strcmp() | 二進(jìn)制安全的字符串比較(區(qū)分大小寫)。愛掏網(wǎng) - it200.com |
strcoll() | 基于Locale的二進(jìn)制比較(區(qū)分大小寫) |
strcspn() | 用于反轉(zhuǎn)字符串。愛掏網(wǎng) - it200.com |
stripcslashes() | 用于取消使用addcslashes()引用的字符串。愛掏網(wǎng) - it200.com |
stripos() | 用于返回一個字符串在另一個字符串中第一次出現(xiàn)的位置。愛掏網(wǎng) - it200.com |
stristr() | 不區(qū)分大小寫的strstr函數(shù) |
strlen() | 用于返回一個字符串的長度。愛掏網(wǎng) - it200.com |
strncasecmp() | 二進(jìn)制安全的不區(qū)分大小寫的字符串比較。愛掏網(wǎng) - it200.com |
strnatcasecmp() | 使用“自然排序”算法進(jìn)行兩個字符串的不區(qū)分大小寫比較 |
strnatcmp() | 使用“自然排序”算法進(jìn)行兩個字符串的區(qū)分大小寫比較 |
strncmp() | 比較前n個字符 |
strpbrk() | 在字符串中搜索一組字符中的任意字符 |
strripos() | 在字符串中查找不區(qū)分大小寫的子字符串最后出現(xiàn)的位置 |
strrpos() | 在字符串中查找子字符串最后出現(xiàn)的位置 |
strpos() | 用于返回一個字符串在另一個字符串中第一次出現(xiàn)的位置。愛掏網(wǎng) - it200.com |
strrchr() | 用于找到一個字符串在另一個字符串中最后一次出現(xiàn)的位置。愛掏網(wǎng) - it200.com |
strrev() | 用于反轉(zhuǎn)一個字符串。愛掏網(wǎng) - it200.com |
strspn() | 查找字符串的初始長度 |
strstr() | 查找一個字符串的出現(xiàn)。愛掏網(wǎng) - it200.com |
strtok() | 將字符串分割成較小的字符串 |
strtolower() | 將字符串轉(zhuǎn)換為小寫 |
strtoupper() | 將字符串轉(zhuǎn)換為大寫字母 |
strtr() | 在字符串中翻譯或替換特定字符或子字符串 |
str_getcsv() | 將CSV字符串解析為數(shù)組 |
str_ireplace() | 在字符串中替換一些字符(不區(qū)分大小寫) |
str_pad() | 將字符串填充到新的長度 |
str_repeat() | 重復(fù)一個字符串指定的次數(shù) |
str_replace() | 將搜索字符串的所有出現(xiàn)替換為替換字符串 |
str_rot13() | 用于對字符串進(jìn)行ROT13編碼。愛掏網(wǎng) - it200.com |
str_shuffle() | 用于隨機(jī)打亂字符串中的所有字符。愛掏網(wǎng) - it200.com |
str_split() | 用于將字符串拆分為數(shù)組。愛掏網(wǎng) - it200.com |
strcoll() | 是基于地區(qū)的字符串比較。愛掏網(wǎng) - it200.com |
strip_tags() | 用于從字符串中刪除HTML和PHP標(biāo)簽。愛掏網(wǎng) - it200.com |
str_word_count() | 用于計算字符串中單詞的數(shù)量。愛掏網(wǎng) - it200.com |
substr() | 返回字符串的一部分。愛掏網(wǎng) - it200.com |
substr_compare() | 從偏移量開始比較兩個字符串,比較長度為字符的長度。愛掏網(wǎng) - it200.com(二進(jìn)制安全比較) |
< a> substr_count() | 計算一個子字符串出現(xiàn)的次數(shù) |
substr_replace() | 用另一個子串替換字符串的一部分 |
trim() | 從字符串的開頭和結(jié)尾刪除空格或其他字符。愛掏網(wǎng) - it200.com |
ucfirst() | 將字符串的第一個字符轉(zhuǎn)換為大寫 |
ucwords() | 將字符串中每個單詞的第一個字符轉(zhuǎn)換為大寫 |
vfprintf() | 將格式化的字符串寫入流中 |
vprintf() | 根據(jù)格式將輸出顯示為格式化的字符串 |
vsprintf() | 返回一個格式化的字符串 |
wordwrap() | 將字符串按照給定的字符數(shù)進(jìn)行換行 |
PHP strtolower()函數(shù)
strtolower()函數(shù)返回小寫字母的字符串。愛掏網(wǎng) - it200.com
語法
string strtolower ( string $string )
示例
<?php
str="My name is KHAN";str=strtolower(str);
echostr;
?>
輸出:
my name is khan
PHP strtoupper() 函數(shù)
strtoupper() 函數(shù)返回一個大寫字母的字符串。愛掏網(wǎng) - it200.com
語法
string strtoupper ( string $string )
示例
<?php
str="My name is KHAN";str=strtoupper(str);
echostr;
?>
輸出:
MY NAME IS KHAN
PHP ucfirst()函數(shù)
ucfirst()函數(shù)將字符串的第一個字符轉(zhuǎn)換為大寫。愛掏網(wǎng) - it200.com它不會改變其他字符的大小寫。愛掏網(wǎng) - it200.com
語法
string ucfirst ( string $str )
示例
<?php
str="my name is KHAN";str=ucfirst(str);
echostr;
?>
輸出:
My name is KHAN
PHP lcfirst() 函數(shù)
lcfirst() 函數(shù)將字符串的首字母轉(zhuǎn)換為小寫。愛掏網(wǎng) - it200.com它不會改變其他字符的大小寫。愛掏網(wǎng) - it200.com
語法
string lcfirst ( string $str )
示例
<?php
str="MY name IS KHAN";str=lcfirst(str);
echostr;
?>
輸出:
mY name IS KHAN
PHP ucwords() 函數(shù)
ucwords() 函數(shù)將每個單詞的首字母轉(zhuǎn)換為大寫,并返回字符串。愛掏網(wǎng) - it200.com
語法
string ucwords ( string $str )
示例
<?php
str="my name is Sonoo jaiswal";str=ucwords(str);
echostr;
?>
輸出:
My Name Is Sonoo Jaiswal
PHP strrev() 函數(shù)
strrev() 函數(shù)返回反轉(zhuǎn)后的字符串。愛掏網(wǎng) - it200.com
語法
string strrev ( string $string )
示例
<?php
str="my name is Sonoo jaiswal";str=strrev(str);
echostr;
?>
輸出:
lawsiaj oonoS si eman ym
PHP strlen()函數(shù)
strlen()函數(shù)返回字符串的長度。愛掏網(wǎng) - it200.com
語法
int strlen ( string $string )
示例
<?php
str="my name is Sonoo jaiswal";str=strlen(str);
echostr;
?>
輸出:
24
聲明:所有內(nèi)容來自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。