3v4l.org

run code in 300+ PHP versions simultaneously
<?php $members_login_history = '[{"i":"1","d":"2020-05-28"},{"i":"1","d":"2020-05-28"},{"i":"1","d":"2020-05-29"},{"i":"1","d":"2020-06-15"},{"i":"1","d":"2020-06-15"},{"i":"1","d":"2020-06-30"},{"i":"2","d":"2020-06-30"},{"i":"2","d":"2020-06-30"},{"i":"2","d":"2020-06-30"},{"i":"2","d":"2020-06-30"},{"i":"2","d":"2020-06-30"},{"i":"3","d":"2020-06-30"},{"i":"3","d":"2020-07-01"},{"i":"4","d":"2020-08-26"},{"i":"6","d":"2020-08-26"},{"i":"6","d":"2020-09-23"},{"i":"6","d":"2020-10-12"},{"i":"6","d":"2020-10-12"},{"i":"7","d":"2020-10-12"},{"i":"7","d":"2020-10-12"},{"i":"7","d":"2020-10-14"},{"i":"7","d":"2020-10-14"},{"i":"7","d":"2020-10-21"},{"i":"7","d":"2020-11-12"},{"i":"7","d":"2020-11-12"},{"i":"7","d":"2020-12-16"},{"i":"7","d":"2020-12-16"},{"i":"8","d":"2021-01-06"},{"i":"9","d":"2021-01-13"},{"i":"9","d":"2021-01-20"},{"i":"9","d":"2021-01-22"},{"i":"10","d":"2021-01-25"},{"i":"10","d":"2021-02-10"},{"i":"11","d":"2021-02-10"}]'; $id=7; preg_match_all("/i\":\"".$id."\",\"d\":\"([0-9-]+)\"/", $members_login_history, $matches); $dates = array(); $date = '2021-01-01'; $end_date = '2021-02-28'; while($date<=$end_date){ $dates[] = $date; $date = date("Y-m-d", strtotime($date." +1 day")); } print_r($dates); print_r($matches);
Output for 7.3.0 - 7.3.28, 7.4.0 - 7.4.16, 8.0.0 - 8.0.3
Array ( [0] => 2021-01-01 [1] => 2021-01-02 [2] => 2021-01-03 [3] => 2021-01-04 [4] => 2021-01-05 [5] => 2021-01-06 [6] => 2021-01-07 [7] => 2021-01-08 [8] => 2021-01-09 [9] => 2021-01-10 [10] => 2021-01-11 [11] => 2021-01-12 [12] => 2021-01-13 [13] => 2021-01-14 [14] => 2021-01-15 [15] => 2021-01-16 [16] => 2021-01-17 [17] => 2021-01-18 [18] => 2021-01-19 [19] => 2021-01-20 [20] => 2021-01-21 [21] => 2021-01-22 [22] => 2021-01-23 [23] => 2021-01-24 [24] => 2021-01-25 [25] => 2021-01-26 [26] => 2021-01-27 [27] => 2021-01-28 [28] => 2021-01-29 [29] => 2021-01-30 [30] => 2021-01-31 [31] => 2021-02-01 [32] => 2021-02-02 [33] => 2021-02-03 [34] => 2021-02-04 [35] => 2021-02-05 [36] => 2021-02-06 [37] => 2021-02-07 [38] => 2021-02-08 [39] => 2021-02-09 [40] => 2021-02-10 [41] => 2021-02-11 [42] => 2021-02-12 [43] => 2021-02-13 [44] => 2021-02-14 [45] => 2021-02-15 [46] => 2021-02-16 [47] => 2021-02-17 [48] => 2021-02-18 [49] => 2021-02-19 [50] => 2021-02-20 [51] => 2021-02-21 [52] => 2021-02-22 [53] => 2021-02-23 [54] => 2021-02-24 [55] => 2021-02-25 [56] => 2021-02-26 [57] => 2021-02-27 [58] => 2021-02-28 ) Array ( [0] => Array ( [0] => i":"7","d":"2020-10-12" [1] => i":"7","d":"2020-10-12" [2] => i":"7","d":"2020-10-14" [3] => i":"7","d":"2020-10-14" [4] => i":"7","d":"2020-10-21" [5] => i":"7","d":"2020-11-12" [6] => i":"7","d":"2020-11-12" [7] => i":"7","d":"2020-12-16" [8] => i":"7","d":"2020-12-16" ) [1] => Array ( [0] => 2020-10-12 [1] => 2020-10-12 [2] => 2020-10-14 [3] => 2020-10-14 [4] => 2020-10-21 [5] => 2020-11-12 [6] => 2020-11-12 [7] => 2020-12-16 [8] => 2020-12-16 ) )