<?php
$ret="Updated Date: 07-feb-2014 Creation Date: 07-feb-2014 Expiration Date: 07-feb-2015 >>> Last update of whois database: Tue, 30 Sep 2014 06:37:52 UTC <<< NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring registrar";
$str=explode("Creation Date:",$ret); echo rtrim($str[1],"Expiration");
?>
这是我的PHP代码,我使用rtrim但它返回
07-feb-2014 Expiration Date: 07-feb-2015 >>> Last update of whois database: Tue, 30 Sep 2014 06:37:52 UTC <<< NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring regis
但我需要07-feb-2014
作为输出,我能为此做些什么。
答案 0 :(得分:0)
为什么不尝试使用正则表达式匹配字符串?
以下代码将输出您想要的内容:
$ret="Updated Date: 07-feb-2014 Creation Date: 07-feb-2014 Expiration Date: 07-feb-2015 >>> Last update of whois database: Tue, 30 Sep 2014 06:37:52 UTC <<< NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring registrar";
preg_match("/.*Creation Date: (.*?) /", $ret, $matches);
echo $matches[1];
答案 1 :(得分:0)
试试这个,
$ret="Updated Date: 07-feb-2014 Creation Date: 07-feb-2014 Expiration Date: 07-feb-2015 >>> Last update of whois database: Tue, 30 Sep 2014 06:37:52 UTC <<< NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring registrar";
$str=explode("Creation Date:",$ret);
$str2=explode("Expiration Date:",$str[1]); echo ($str2[0]);