3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result5 = array( array('start_date' => '2005-10-12', 'name_event' => 'test1'), array('start_date' => '2006-10-12', 'name_event' => 'test2'), ); $daily_html = ''; foreach($result5 as $row5) { $time=strtotime($row5['start_date']); $day = date("d",$time); $month= date("m",$time); $month2= date("F",$time); $year=date("Y",$time); $eventName = "$day $month $year ".$row5['name_event'] ; // this show me correct addDailyHtml( "Event: " . $eventName, "$day-$month-$year", null, $daily_html);// there is some problem } var_dump($daily_html); function addDailyHtml( $html, $start_date_string, $end_date_string = null, &$daily_html ) { static $htmlCount = 0; $start_date = strtotime($start_date_string); if( $end_date_string ) { $end_date = strtotime($end_date_string); } else { $end_date = $start_date; } $working_date = $start_date; do { $tDate = getdate($working_date); $working_date += 86400; $daily_html[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; } while( $working_date < $end_date + 1 ); $htmlCount++; }
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Optional parameter $end_date_string declared before required parameter $daily_html is implicitly treated as a required parameter in /in/4GlKl on line 24 Fatal error: Uncaught Error: Cannot use string offset as an array in /in/4GlKl:37 Stack trace: #0 /in/4GlKl(20): addDailyHtml('Event: 12 10 20...', '12-10-2005', NULL, '') #1 {main} thrown in /in/4GlKl on line 37
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Deprecated: Required parameter $daily_html follows optional parameter $end_date_string in /in/4GlKl on line 24 Fatal error: Uncaught Error: Cannot use string offset as an array in /in/4GlKl:37 Stack trace: #0 /in/4GlKl(20): addDailyHtml('Event: 12 10 20...', '12-10-2005', NULL, '') #1 {main} thrown in /in/4GlKl on line 37
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Cannot use string offset as an array in /in/4GlKl:37 Stack trace: #0 /in/4GlKl(20): addDailyHtml('Event: 12 10 20...', '12-10-2005', NULL, '') #1 {main} thrown in /in/4GlKl on line 37
Process exited with code 255.
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
array(2) { [2005]=> array(1) { [10]=> array(1) { [12]=> array(1) { [0]=> string(23) "Event: 12 10 2005 test1" } } } [2006]=> array(1) { [10]=> array(1) { [12]=> array(1) { [1]=> string(23) "Event: 12 10 2006 test2" } } } }
Output for 5.1.0 - 5.1.2
array(1) { [1970]=> array(1) { [1]=> array(1) { [1]=> array(2) { [0]=> string(23) "Event: 12 10 2005 test1" [1]=> string(23) "Event: 12 10 2006 test2" } } } }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5
array(1) { [2018]=> array(1) { [3]=> array(2) { [28]=> array(1) { [0]=> string(23) "Event: 12 10 2005 test1" } [29]=> array(1) { [1]=> string(23) "Event: 12 10 2006 test2" } } } }

preferences:
290.9 ms | 402 KiB | 424 Q