数组函数问题

WBOY
Release: 2016-06-23 14:00:53
Original
815 people have browsed it

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


回复讨论(解决方案)

array_map

$d = array('1394591688','1394591688','1394581688','1394491688');function  cube ( $n ){    return date('Y-m-d',$n) ;}$b  =  array_map ( "cube" ,  $d );$b = array_unique ( $b );var_dump($b);
Copy after login

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

学习了,array_map和array_unique两个小函数,平时都没怎么用

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template