chop函式 PHP chop()函式與示例

2021-10-08 20:37:41 字數 1246 閱讀 8617

chop函式

chop() functionis a string function in php, it is used to remove the whitespaces or/and specified character/string from the end of the string.

chop()函式是php中的字串函式,用於從字串末尾刪除空格或/和指定的字元/字串。

syntax:

句法:

chop(string, [char/string]) : string
here,

這裡,

examples:

例子:

input:

str = "includehelp.com#"

char/string to remove "#"

output:

"includehelp.com"

input:

str = "includehelp.com#"

char/string to remove "com#"

output:

"includehelp."

input:

str = "includehelp.com#"

char/string to remove ".com#"

output:

"includehelp"

php code:

php**:

<?php

$str = "includehelp.com#";

//removing "#"

echo (chop($str, "#")."\n");

//removing "com#"

echo (chop($str, "com#")."\n");

//removing ".com#"

echo (chop($str, ".com#")."\n");

?>

output

輸出量

includehelp.com

includehelp.

includehelp

翻譯自:

chop函式

PHP chop 函式講解

php chop 函式 例項移除字串右側的字元 str 程式設計客棧 hello world echo str echo chop str,world 定義和用法 chop 函式移除字串右側的空白字元或其他預定義字元。語法chop strwww.cppcns.coming,charlist 例項 1...

函式基礎 匿名函式,函式,箭頭函式,立即執行函式

doctype html html lang en head meta charset utf 8 meta name viewport content width device width,initial scale 1.0 title document title head body body ...

函式 常見函式

def fib n if n 1 return 1if n 2 return 1return fib n 1 fib n 2 def hannuo n,a,b,c n 表示有n個盤子 a 代表第乙個塔,開始的塔 b 代表第二個塔,過渡塔 c 代表第三個塔,目標塔 d.在 中n 2,這個分支可以不要,...