PHP chop() 函數(shù)
chop() 函數(shù)用于刪除字符串右側(cè)的空格或其他預(yù)定義字符。愛掏網(wǎng) - it200.com
chop(string,charlist);
注意:chop()函數(shù)與Perl中的chop()函數(shù)不同,Perl中的chop()函數(shù)用于刪除字符串中的最后一個(gè)字符。愛掏網(wǎng) - it200.com
參數(shù) | 描述 | 必選/可選 |
---|---|---|
字符串 | 需要檢查的字符串 | 必選 |
字符列表 | 字符列表參數(shù)為空 | 可選 |
示例1
<?php
str = "Hello World!";
echo "Your string is :".str."<br>";
echo "By using 'chop()' Functions is your string is: ".chop($str,"World!");
?>
輸出:
Your string is :Hello World!
By using 'chop()' Functions is your string is: Hello
示例2
<?php
str = "Hello World!";
echo "Your string is :".str."<br>";
echo "By using 'chop()' Functions is your string is: ".chop($str);
?>
輸出:
Your string is :Hello World!
By using 'chop()' Functions is your string is: Hello World!
示例3
<?php
str = "Hello World!\n\n";
echo "Your string is :".str."<br>";
echo "By using 'chop()' Functions is your string is: ".chop($str,"World!");
?>
輸出:
Your string is :Hello World!
By using 'chop()' Functions is your string is: Hello World!
聲明:所有內(nèi)容來(lái)自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。