如何搜索文本并替换为preg_replace?

时间:2018-01-25 20:50:29

标签: php

我想检查文本是否存在:250000 使用preg_replace或preg_match,然后将其替换为如下所示:

260000

基本上这应该是一个小时一天(25 00:00:00) 我想检查是否是午夜,然后文本将被替换为第二天的日期。

我尝试了什么:

$text = "today250000";
//I need to add the line with the text that I want ($newday0000), but I do not know how
$newday = date("d", strtotime('tomorrow'));

preg_replace($text, $replace, $day);
echo $day;

我也试过了:

if(strpos($text, '250000'..

但它不稳定,它改变了我的txt文件中的大部分时间

1 个答案:

答案 0 :(得分:0)

<?php echo preg_replace($text, $replace, $day); ?>

如果你只是“回复$ day”,那么就没有替换任何内容,只需回复没有preg_replace的日子

相关问题