[英]How can I remove … from a string in PHP?
您好,如果我有以下字符串
這似乎找到了節點...確定,但輸出如下
我該如何刪除...並進行打印? 我正在使用PHP
謝謝!
您應該使用str_replace :
$newString = str_replace('...', '', $string);
對於這些簡單的任務使用正則表達式是過大的, 會損害性能 :
避免使用正則表達式來支持str_replace()和strstr()。 除非確實需要正則表達式,否則不要使用它們。 字符串函數要快得多。
另外,對於簡單的$ strings,您可以使用
$new_string = str_replace('find','replace_with',$old_string);
要使用str_replace刪除“ ...”,只需:
$new_string = str_replace('...','',$old_string);
$new_str = preg_replace('/\.{3,}/', '' , $str);
$str
是原始字符串
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.