3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $table_template = array( 'db' => array( 'from' => 'CASE_ALIGMENT_0', 'select' => array( 'YR' => FALSE, 'REFERENCE' => "upper(###)", 'DESCRIPTION' => "initcap(###)", 'SUPPLIER_LOWER' => "initcap(###)", 'COUNTRY_LOWER' => "upper(###)", 'AMOUNT_LOWER' => '###', 'SUPPLIER_ALIG' => "initcap(###)", 'COUNTRY_ALIG' => "upper(###)", 'AMOUNT_ALIG' => '###', 'DIFF_PERC' => '###', 'DIFF' => '###', ), 'where' => array( 'YR' => array('LIKE', "%" ) ), ), 'filters' => array( 'year_min' => array( 'type' => 'year', 'description' => 'From year', 'where' => array( 'YR' => array( '>=', '2013' ) ), ), 'year_max' => array( 'type' => 'year', 'description' => 'To year', 'where' => array( 'YR' => array( '<=', '2013' ) ), ), ), 'dynamic' => TRUE, 'editable' => FALSE, 'number' => 6, 'title' => "Cases of alignment for contracts and orders<br><small>since 1994</small>", 'subtitle' => NULL, // TODO: Build graph queries and use them 'graph' => NULL, // array('query' => "select YR, to_char(to_number(sum(AMOUNT_ALIG)), '999G999G999', 'NLS_NUMERIC_CHARACTERS = '', ''') from CASE_ALIGMENT_0 group by YR order by YR;"), 'headers' => array( array( 'from_db' => FALSE, 'layout' => array( array( 'colspan' => 2, 'class' => "text-center" ), array( 'colspan' => 3, 'class' => "text-center border-left" ), array( 'colspan' => 3, 'class' => "text-center border-left" ), array( 'colspan' => 2, 'class' => "text-center border-left" ), ), 'data' => array( "<h3>Enquiry</h3>", "<h3>Lowest bid</h3>", "<h3>Alignment</h3>", "<h3>Difference</h3>", ), ), array( 'from_db' => TRUE, 'layout' => array( 'REFERENCE' => array( 'class' => "text-center" ), 'DESCRIPTION' => array( 'class' => "text-center" ), 'SUPPLIER_LOWER' => array( 'class' => "text-center border-left" ), 'COUNTRY_LOWER' => array( 'class' => "text-center" ), 'AMOUNT_LOWER' => array( 'class' => "text-center" ), 'SUPPLIER_ALIG' => array( 'class' => "text-center border-left" ), 'COUNTRY_ALIG' => array( 'class' => "text-center" ), 'AMOUNT_ALIG' => array( 'class' => "text-center" ), 'DIFF_PERC' => array( 'class' => "text-center border-left" ), 'DIFF' => array( 'class' => "text-center" ), ), 'data' => array( 'REFERENCE' => "Reference", 'DESCRIPTION' => "Description", 'SUPPLIER_LOWER' => "Supplier", 'COUNTRY_LOWER' => "Country", 'AMOUNT_LOWER' => "Bid (CHF)", 'SUPPLIER_ALIG' => "Supplier", 'COUNTRY_ALIG' => "Country", 'AMOUNT_ALIG' => "Initial bid (CHF)", 'DIFF_PERC' => "%", 'DIFF' => "CHF", ), ), ), 'body' => array( 'layout' => array( 'REFERENCE' => array( 'class' => "no-wrap" ), 'DESCRIPTION' => array( 'class' => "text-min-width" ), 'SUPPLIER_LOWER' => array( 'class' => "border-left" ), 'COUNTRY_LOWER' => array( 'class' => 'no-wrap' ), 'AMOUNT_LOWER' => array( 'class' => "text-right no-wrap", 'data-format' => 'currency' ), 'SUPPLIER_ALIG' => array( 'class' => "border-left" ), 'COUNTRY_ALIG' => array( 'class' => 'no-wrap' ), 'AMOUNT_ALIG' => array( 'class' => "text-right no-wrap", 'data-format' => 'currency' ), 'DIFF_PERC' => array( 'class' => "text-right no-wrap border-left", 'data-format' => 'percentage' ), 'DIFF' => array( 'class' => "text-right no-wrap", 'data-format' => 'currency' ), ), 'format' => array( 'AMOUNT_LOWER' => array( 'format_french_number', 'format_no_decimals' ), 'AMOUNT_ALIG' => array( 'format_french_number', 'format_no_decimals' ), 'COUNTRY_LOWER' => 'format_line_break', 'COUNTRY_ALIG' => 'format_line_break', 'DIFF_PERC' => 'format_percent', 'DIFF' => array( 'format_french_number', 'format_no_decimals' ), ), ), 'footers' => array( array( 'from_db' => TRUE, 'layout' => NULL, 'data' => array( 'REFERENCE' => "Reference", 'DESCRIPTION' => "Description", 'SUPPLIER_LOWER' => "Supplier", 'COUNTRY_LOWER' => "Country", 'AMOUNT_LOWER' => "Bid (CHF)", 'SUPPLIER_ALIG' => "Supplier", 'COUNTRY_ALIG' => "Country", 'AMOUNT_ALIG' => "Initial bid (CHF)", 'DIFF_PERC' => "%", 'DIFF' => "CHF", ), ), ), ); echo json_encode($table_template);
based on kpmA8
Output for 5.2.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
{"db":{"from":"CASE_ALIGMENT_0","select":{"YR":false,"REFERENCE":"upper(###)","DESCRIPTION":"initcap(###)","SUPPLIER_LOWER":"initcap(###)","COUNTRY_LOWER":"upper(###)","AMOUNT_LOWER":"###","SUPPLIER_ALIG":"initcap(###)","COUNTRY_ALIG":"upper(###)","AMOUNT_ALIG":"###","DIFF_PERC":"###","DIFF":"###"},"where":{"YR":["LIKE","%"]}},"filters":{"year_min":{"type":"year","description":"From year","where":{"YR":[">=","2013"]}},"year_max":{"type":"year","description":"To year","where":{"YR":["<=","2013"]}}},"dynamic":true,"editable":false,"number":6,"title":"Cases of alignment for contracts and orders<br><small>since 1994<\/small>","subtitle":null,"graph":null,"headers":[{"from_db":false,"layout":[{"colspan":2,"class":"text-center"},{"colspan":3,"class":"text-center border-left"},{"colspan":3,"class":"text-center border-left"},{"colspan":2,"class":"text-center border-left"}],"data":["<h3>Enquiry<\/h3>","<h3>Lowest bid<\/h3>","<h3>Alignment<\/h3>","<h3>Difference<\/h3>"]},{"from_db":true,"layout":{"REFERENCE":{"class":"text-center"},"DESCRIPTION":{"class":"text-center"},"SUPPLIER_LOWER":{"class":"text-center border-left"},"COUNTRY_LOWER":{"class":"text-center"},"AMOUNT_LOWER":{"class":"text-center"},"SUPPLIER_ALIG":{"class":"text-center border-left"},"COUNTRY_ALIG":{"class":"text-center"},"AMOUNT_ALIG":{"class":"text-center"},"DIFF_PERC":{"class":"text-center border-left"},"DIFF":{"class":"text-center"}},"data":{"REFERENCE":"Reference","DESCRIPTION":"Description","SUPPLIER_LOWER":"Supplier","COUNTRY_LOWER":"Country","AMOUNT_LOWER":"Bid (CHF)","SUPPLIER_ALIG":"Supplier","COUNTRY_ALIG":"Country","AMOUNT_ALIG":"Initial bid (CHF)","DIFF_PERC":"%","DIFF":"CHF"}}],"body":{"layout":{"REFERENCE":{"class":"no-wrap"},"DESCRIPTION":{"class":"text-min-width"},"SUPPLIER_LOWER":{"class":"border-left"},"COUNTRY_LOWER":{"class":"no-wrap"},"AMOUNT_LOWER":{"class":"text-right no-wrap","data-format":"currency"},"SUPPLIER_ALIG":{"class":"border-left"},"COUNTRY_ALIG":{"class":"no-wrap"},"AMOUNT_ALIG":{"class":"text-right no-wrap","data-format":"currency"},"DIFF_PERC":{"class":"text-right no-wrap border-left","data-format":"percentage"},"DIFF":{"class":"text-right no-wrap","data-format":"currency"}},"format":{"AMOUNT_LOWER":["format_french_number","format_no_decimals"],"AMOUNT_ALIG":["format_french_number","format_no_decimals"],"COUNTRY_LOWER":"format_line_break","COUNTRY_ALIG":"format_line_break","DIFF_PERC":"format_percent","DIFF":["format_french_number","format_no_decimals"]}},"footers":[{"from_db":true,"layout":null,"data":{"REFERENCE":"Reference","DESCRIPTION":"Description","SUPPLIER_LOWER":"Supplier","COUNTRY_LOWER":"Country","AMOUNT_LOWER":"Bid (CHF)","SUPPLIER_ALIG":"Supplier","COUNTRY_ALIG":"Country","AMOUNT_ALIG":"Initial bid (CHF)","DIFF_PERC":"%","DIFF":"CHF"}}]}
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/5sssJ on line 130
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/5sssJ on line 130
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/5sssJ on line 130
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/5sssJ on line 130