Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/02/2019, 14:45
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 9 meses
Puntos: 379
Respuesta: Listar años de muchas fechas

Es muy sencillo solo crea una función que lo haga

Código PHP:
Ver original
  1. $data = array(
  2. '12/10/1989',
  3. '11/05/1989',
  4. '02/12/2011'
  5. );
  6.  
  7. function getYearsFromArray(Array $data) {
  8.     return array_map(function($data){
  9.         return (new DateTime($data))->format('Y');
  10.      }, $data);
  11. }
  12.  
  13. var_dump(getYearsFromArray($data));
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.