PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function pushEveryThreeMonths($originalArray) { $newArray = []; $interval = new DateInterval('P3M'); echo $startDate = new DateTime(); // current date and time /*foreach ($originalArray as $element) { $newArray[] = $element; // push the element to the new array // Add three months to the start date $startDate->add($interval); // Check if the start date is in the future if ($startDate > new DateTime()) { break; // exit the loop if it's in the future } } return $newArray;*/ print_r($interval); } // Example usage: $originalArray = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']; $newArray = pushEveryThreeMonths($originalArray); // Output the new array print_r($newArray);
Show:  
Copy Clear