\n\n不使用 trim: Hello World!
使用 trim: Hello World!\n<\/body>\n<\/html><\/pre>\n\n

以上代碼的瀏覽器輸出如下:<\/p>\n\n

不使用 trim: Hello World!\n使用 trim: Hello World!\n<\/pre>\n\n

原文地址:http:\/\/www.manongjc.com\/article\/827.html<\/p>\n

相關(guān)閱讀:<\/p>\n

php trim() 函數(shù)移除字符串兩側(cè)的空白字符或其他預(yù)定義字符<\/p>\n

php rtrim() 函數(shù)移除字符串右側(cè)的空白字符或其他預(yù)定義字符<\/p>\n

php trim() 函數(shù)移除字符串兩側(cè)的空白字符或其他預(yù)定義字符<\/p>\n"}

国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
php trim() 函數(shù)實(shí)例講解,trim實(shí)例講解
定義和用法
相關(guān)函數(shù):
語法
技術(shù)細(xì)節(jié)
實(shí)例
Home php教程 php手冊 php trim() 函數(shù)實(shí)例講解,trim實(shí)例講解

php trim() 函數(shù)實(shí)例講解,trim實(shí)例講解

Jun 13, 2016 am 08:40 AM
trim function

php 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ī)定從字符串中刪除哪些字符。如果被省略,則移除以下所有字符:

  • "\0" - NULL
  • "\t" - 制表符
  • "\n" - 換行
  • "\x0B" - 垂直制表符
  • "\r" - 回車
  • " " - 空格

技術(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ù)定義字符

Statement of this Website
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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)