php trim() 函數(shù)實(shí)例講解,trim實(shí)例講解
Jun 13, 2016 am 08:40 AMphp trim() 函數(shù)實(shí)例講解,trim實(shí)例講解
php trim() 函數(shù)移除字符串兩側(cè)的空白字符或其他預(yù)定義字符,本文章向碼農(nóng)介紹php trim() 函數(shù)的使用方法和實(shí)例,感興趣的碼農(nóng)可以參考一下。
定義和用法
trim() 函數(shù)移除字符串兩側(cè)的空白字符或其他預(yù)定義字符。
相關(guān)函數(shù):
- ltrim()?- 移除字符串左側(cè)的空白字符或其他預(yù)定義字符
- rtrim()?- 移除字符串右側(cè)的空白字符或其他預(yù)定義字符
?
語法
trim(string,charlist)
參數(shù) | 描述 |
---|---|
string | 必需。規(guī)定要檢查的字符串。 |
charlist |
可選。規(guī)定從字符串中刪除哪些字符。如果被省略,則移除以下所有字符:
|
技術(shù)細(xì)節(jié)
返回值: | 返回被修改的字符串 |
PHP 版本: | 4+ |
更新日志: | 在 PHP 4.1 中,新增了 charlist 參數(shù)。 |
實(shí)例
移除字符串兩側(cè)的空格:
<?php $str = " Hello World! "; echo "不使用 trim: " . $str; echo "<br>"; echo "使用 trim: " . trim($str); ?>
在線運(yùn)行
以上代碼的 HTML 輸出如下(請查看源代碼):
<!DOCTYPE html> <html> <body> 不使用 trim: Hello World! <br>使用 trim: Hello World! </body> </html>
以上代碼的瀏覽器輸出如下:
不使用 trim: Hello World! 使用 trim: Hello World!
原文地址:http://www.manongjc.com/article/827.html
相關(guān)閱讀:
php trim() 函數(shù)移除字符串兩側(cè)的空白字符或其他預(yù)定義字符
php rtrim() 函數(shù)移除字符串右側(cè)的空白字符或其他預(yù)定義字符
php trim() 函數(shù)移除字符串兩側(cè)的空白字符或其他預(yù)定義字符

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

Clothoff.io
AI clothes remover

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

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)
