Last active
February 12, 2019 03:02
-
-
Save janrsilva/8134dc39b5f6d59c4c94f1373ff4d8d6 to your computer and use it in GitHub Desktop.
Using PHP internals (no frameworks). Please create a new array with only the entries from July.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = [ | |
(object) [ | |
'name' => 'Ring [A0123]', | |
'price' => 25, | |
'created_at' => '2016-07-20', | |
], | |
(object) [ | |
'name' => 'Pendant [A0124]', | |
'price' => 55, | |
'created_at' => '2016-07-17', | |
], | |
(object) [ | |
'name' => 'Earrings [A0125]', | |
'price' => 15, | |
'created_at' => '2016-06-20', | |
], | |
(object) [ | |
'name' => 'Bracelet [ABCDE]', | |
'price' => 15, | |
'created_at' => '2016-06-23', | |
] | |
]; | |
var_dump(array_filter($data, function($product){ | |
return date("m", strtotime($product->created_at)) === "07"; | |
})); | |
//Hi everyone, you can comment it. =) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment