我從url中檢索日期字符串。 我的檢索日期字符串的代碼是在日期字符串下面給出的,存儲在$ item [6]中。它可以正常工作。但是在日期字符串中日期會重複多次。我只想顯示唯一的日期不是所有的日期。我可以做this.please幫助我感謝。如何在所有重複多次的日期字符串中只顯示唯一的日期字符串
function curlUsingGet($url, $data)
{
if(empty($url) OR empty($data))
{
return 'Error: invalid Url or Data';
}
$fields_string = '';
foreach($data as $key=>$value) { $fields_string .= $key.'='.urlencode($value).'&'; }
rtrim($fields_string,'&');
$urlStringData = $url.'?'.$fields_string;
$_SESSION['urlStringData']=$urlStringData;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,0);
curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT
6.1)");
curl_setopt($ch, CURLOPT_COOKIESESSION,true);
$header = array("Cache-Control: no-cache");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FRESH_CONNECT,true);
curl_setopt($ch, CURLOPT_URL,$urlStringData);
$return = curl_exec($ch);
$date = explode('|',$return);
for($i=0;$i<count($date);$i++)
{
$arraylist[]= $date[$i];
}
$arraylist;
foreach($arraylist as $allitem)
{
$item= explode('~',$allitem);
print"</br>";
echo $item[6];
}
curl_close($ch);
}
$a='UMESH NARAIN SHARMA';
$b='ald';
$data = array('u' => $a , 'b'=> $b);
echo
curlUsingGet('http://localhost/causelist/CauseListData',$data);
?>
the output is
2014-03-10
2014-03-10
2014-03-06
2014-03-06
2014-03-06
2014-03-06
2014-03-06
2014-03-06
2014-03-06
2014-03-06
2014-03-06
2014-03-06
2014-03-10
2014-03-10