【问题标题】:using preg_replace or preg_match_all function to replace a string使用 preg_replace 或 preg_match_all 函数替换字符串
【发布时间】:2020-06-18 01:15:11
【问题描述】:
<input type="text" name="name" value="">

我正在尝试使用 preg_replace 从字符串中删除 value="" 任何人都可以帮助我完全不了解正则表达式

【问题讨论】:

标签: php html regex


【解决方案1】:

如果只有value="",则不需要preg_replace。使用str_replace,它比使用正则表达式更快。

$string = '<input type="text" name="name" value="">';

print(str_replace('value=""','',$string)); //<input type="text" name="name" >

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多