PHP code example of ropendev / phptojs

1. Go to this page and download the library: Download ropendev/phptojs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ropendev / phptojs example snippets


use \rOpenDev\PHPToJS;

$options = (object) array(
    'title' => (object) array(
        'label' => 'PHP To JS charts',
        'class' => 'titlechart',
        'formatter' => 'function(s) { return s.replace("-", "/"); }',
    ),
    'data' => array(2014,2013,2012,2011)
);
echo PHPToJS::render($options);

{title:{label:"PHP To JS charts",class:"titlechart",formatter:function(s) { return s.replace("-", "/"); }},data:[2014,2013,2012,2011]}

{
	title: {
		label: "PHP To JS charts",
		class: "titlechart",
		formatter: function(s) { return s.replace("-", "/"); }
	},
	data: [
		2014,
		2013,
		2012,
		2011
	]
}