-2
<?php
$field_format = array('format'=>"date('Y-m-d',strtotime(created_date))");//array define here
echo 'default output '.date('Y-m-d',strtotime('26-09-2016'));
echo nl2br('<br/>');
echo nl2br('<br/>');
if (array_key_exists('format', $field_format)) {
$value_in_format = $field_format['format'];
$value_in_format = preg_replace('/created_date/','26-09-2016', $value_in_format);
//打印的var_dump格式我想执行此代码并使用PHP默认输出格式输出?
var_dump(preg_replace('/created_date/','26-09-2016', $value_in_format));
echo nl2br('<br/>');
echo nl2br('<br/>');
echo $value_in_format;
//我想这个输出应该是一样的默认输出
echo nl2br('<br/>');
echo nl2br('<br/>');
}
?>
我想运行PHP的日期函数来得到的preg_replace第二个参数值。但它显示为字符串格式,如date('Ym-d',strtotime(26-09-2016)) –
它以字符串格式显示,因为在数组中定义错误:this:array('format'=>“date ( 'YM-d',的strtotime(CREATED_DATE))“);应该是:array('format'=> date('Y-m-d',strtotime(“Ymd”))); – mihutz
但我想从preg_replace –