3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $indices = array( array( 'name' => 'DJIA', 'lastPrice' => 18047.58, 'change' => 28.23, 'changePercent' => 0.16 ), array( 'name' => 'Nasdaq', 'lastPrice' => 4899.27, 'change' => 5.43, 'changePercent' => 0.11 ), array( 'name' => 'S&P 500', 'lastPrice' => 2100.34, 'change' => 3.35, 'changePercent' => 0.16 ) ); $bonds = array( array( 'name' => '5 Year Bond', 'lastPrice' => 1.63, 'change' => 0.0098, 'changePercent' => 0.61 ), array( 'name' => '10 Year Bond', 'lastPrice' => 2.14, 'change' => -0.0016, 'changePercent' => -0.07 ), array( 'name' => '30 Year Bond', 'lastPrice' => 2.72, 'change' => -0.0154, 'changePercent' => -0.56 ), ); echo json_encode(array('indices' => $indices, 'bonds' => $bonds, 'news' => array('headline' => 'headline', 'body' => 'BODY', 'timestamp' => '1426788611')));
based on iBh0c
Output for 5.2.0 - 7.2.0
{"indices":[{"name":"DJIA","lastPrice":18047.58,"change":28.23,"changePercent":0.16},{"name":"Nasdaq","lastPrice":4899.27,"change":5.43,"changePercent":0.11},{"name":"S&P 500","lastPrice":2100.34,"change":3.35,"changePercent":0.16}],"bonds":[{"name":"5 Year Bond","lastPrice":1.63,"change":0.0098,"changePercent":0.61},{"name":"10 Year Bond","lastPrice":2.14,"change":-0.0016,"changePercent":-0.07},{"name":"30 Year Bond","lastPrice":2.72,"change":-0.0154,"changePercent":-0.56}],"news":{"headline":"headline","body":"BODY","timestamp":"1426788611"}}
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/ghnHu on line 43
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/ghnHu on line 43
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/ghnHu on line 43
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/ghnHu on line 43