3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data[0] = (object) array( 'time' => '1403071646', 'netin' => '17.75', 'netout' => '22.5' ); $data[1] = (object) array( 'time' => '1403071647', 'netin' => '17.75', 'netout' => '22.5' ); $data[2] = (object) array( 'time' => '1403071649', 'netin' => '17.75', 'netout' => '22.5' ); // trying to make lines 15-19 become the following: // $output .= "{'x':'".date('Y-m-d H:i:s', $stat->time)."','y':'".number_format(round($stat->netin) / 1024, 2)."','z':'".number_format(round($stat->netout) / 1024, 2)."'}"; function chart_data($data, $items) { $count = count($data); $i = 1; $output = ''; foreach ($data as $stat) { $output .= '{'; foreach ($items as $key => $func) { $output .= "'".$key."':'".$func($stat)."'"; } $output .= '}'; if ($i < $count) { $output .= ","; } $output .= "\n"; $i++; } echo $output; } $items = array( 'x' => function ($stat) { return date('Y-m-d H:i:s', $stat['time']); }, 'y' => function ($stat) { return number_format(round($stat['netin']) / 1024, 2); }, 'z' => function ($stat) { return number_format(round($stat['netout']) / 1024, 2); } ); chart_data($data, $items);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/lSd2g:34 Stack trace: #0 /in/lSd2g(20): {closure}(Object(stdClass)) #1 /in/lSd2g(45): chart_data(Array, Array) #2 {main} thrown in /in/lSd2g on line 34
Process exited with code 255.

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:
41.17 ms | 401 KiB | 8 Q