3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 echo '<br/>'; 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 7.1.0
<br/> Fatal error: Uncaught Error: Cannot use string offset as an array in /in/uKGEj:38 Stack trace: #0 /in/uKGEj(21): addDailyHtml('Event: 12 10 20...', '12-10-2005', NULL, '') #1 {main} thrown in /in/uKGEj on line 38
Process exited with code 255.
Output for 5.1.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
<br/><br/>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
<br/><br/>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 - 5.0.5
<br/><br/>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" } } } }