不推荐使用:不推荐使用split()函数.如何重写此语句? [英] Deprecated: Function split() is deprecated. How to rewrite this statement?
本文介绍了不推荐使用:不推荐使用split()函数.如何重写此语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下语句,使用 split
函数
I have the following statement which worked fine before PHP 5.3 using the split
function:
list($year, $month, $day, $hour, $min, $sec) = split( '[: -]', $post_timestamp );
升级到PHP 5.3后,我收到不赞成使用的警告:
After upgrading to PHP 5.3, I get the Deprecated warning:
不推荐使用:不推荐使用split()函数.
Deprecated: Function split() is deprecated.
我正在尝试解析格式如下的字符串:
I am trying to parse a string with format like:
2010-08-10 23:07:58
2010-08-10 23:07:58
进入其组成部分.
推荐答案
我认为您想要 preg_split .
list($year, $month, $day, $hour, $min, $sec) = preg_split('/[: -]/', $post_timestamp);
这篇关于不推荐使用:不推荐使用split()函数.如何重写此语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文