Home  >  Article  >  Backend Development  >  数组函数有关问题

数组函数有关问题

WBOY
WBOYOriginal
2016-06-13 11:50:491086browse

数组函数问题
PHP数组 给里面每个元素 都用  date("Y-m-d",数组每个元素); 这个函数我忘记叫什么了会 生成新的数组 然后用array_unique取出重复  然后取最大 的 和第二个 怎么写
------解决方案--------------------

$d = array('1394591688','1394591688','1394581688','1394491688');<br /><br />function  cube ( $n )<br />{<br />    return date('Y-m-d',$n) ;<br />}<br />$b  =  array_map ( "cube" ,  $d );<br />rsort( $b );//倒序排序<br />$b = array_unique($b);<br />var_dump($b[0]);//最大的<br />var_dump($b[1]);//第二大的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn