使用PHP中的stripslashes()函数去除字符串中的反斜杠。例如:

$timeArr[0] = stripslashes($timeArr[0]);

在使用preg_match_all()函数匹配字符串时,如果匹配到的字符串中包含反斜杠,可以使用stripslashes()函数去除这些反斜杠。

示例代码:

$data = '备案时间</td><tdclass="z-tl">2023-08-10</td>';
preg_match_all('/备案时间</td><tdclass="z-tl">(.*?)</td>/i', $data, $timeArr);

// 去除反斜杠
$timeArr[0] = stripslashes($timeArr[0]);

// 输出结果
var_dump($timeArr[0]); // 输出:2023-08-10

注意:

stripslashes()函数只去除字符串中的反斜杠,不会去除其他特殊字符。

PHP去除字符串中的反斜杠:stripslashes()函数

原文地址: https://www.cveoy.top/t/topic/lBnv 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录