3v4l.org

run code in 300+ PHP versions simultaneously
<?php $PopulationOfTexas = array( 1999 => 20.56, // in millions 2000 => 21.56, 2001 => 22.56, 2002 => 23.56 ); //generate an array sohwing the difference in each year compared to the previous year $differneces = array(); $lastmonth = null; foreach($PopulationOfTexas as $k=>$v){ if(empty($lastmonth)){$lastmonth = $k; continue;} $differneces[$k] = $k - $lastmonth; $lastmonth = $k; } //print_r($differneces); //get the average difference per year $count = 0; $total = 0; foreach($differneces as $k=>$v){ $count++; $total += $v; } $average = number_format(($total/$count), 2); //print_r($average); //make a prediction $lastitem = array_pop($PopulationOfTexas); print_r($lastitem);
Output for git.master, git.master_jit, rfc.property-hooks
23.56

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
42.92 ms | 401 KiB | 8 Q