से मूल्यों को डुप्लिकेट मैं एक सरणी जो जैसेनिकालें सरणी
Array
(
[0] => stdClass Object
(
[post_date] => 2017-01-04 14:28:00
)
[1] => stdClass Object
(
[post_date] => 2017-01-05 11:06:00
)
[2] => stdClass Object
(
[post_date] => 2017-02-04 14:28:00
)
[3] => stdClass Object
(
[post_date] => 2017-02-04 14:34:00
)
)
मैं substr() फ़ंक्शन का उपयोग किया विशेष भाग
foreach($unique_dates as $val) {
$year=substr($val->post_date,0,4);
$month=substr($val->post_date,5,2);
$monthName = date('F', mktime(0, 0, 0, $month, 10));
echo $monthName." ".$year."<br>";
}
की तरह अब यह दिखा रहा है उत्पादन प्राप्त करने के लिए लग रहा है है -
January 2017
January 2017
February 2017
February 2017
लेकिन मैं चाहता हूँ आउटपुट की तरह -
January 2017
February 2017
मैं इस प्रकार की कोशिश की लेकिन उचित output-
$unique_dates = array_map(
'unserialize',
array_unique(
array_map(
'serialize',
$dates
)
)
);
मैं डुप्लिकेट मान निकालना चाहते हैं नहीं मिला।
यह कैसे संभव है?
धन्यवाद।
कोशिश http://php.net/manual/en/function.array-unique.php देना – xFighter
तो यह आपके सरणी अद्वितीय सही बनाने के लिए किया जाएगा? $ monthName। "" $ $ – rahulsm
@VforVendetta हाँ सही – Deepak