Json encoding with PHP 5.3 -
i trying info json, can hardcode output code needs generated dynamically using mysql info , code calculate results. json output in format:
{ "inits": { "version": "18.05.04_ep1", "source": "live", "lowid": "265067", "highid": "265068", "ql": "300", "name": "ofab shark mk 1", "inits": [ { "-init": "430", "-percent": "100", "-slider": "def>===========][<agg" }, { "-init": "530", "-percent": "90", "-slider": "def>==========][=<agg" }, { "-init": "630", "-percent": "81", "-slider": "def>=========][==<agg" }, { "-init": "730", "-percent": "72", "-slider": "def>========][===<agg" }, { "-init": "830", "-percent": "63", "-slider": "def>=======][====<agg" }, { "-init": "930", "-percent": "54", "-slider": "def>======][=====<agg" }, { "-init": "1030", "-percent": "45", "-slider": "def>=====][======<agg" }, { "-init": "1130", "-percent": "36", "-slider": "def>====][=======<agg" }, { "-init": "1290", "-percent": "27", "-slider": "def>===][========<agg" }, { "-init": "1590", "-percent": "18", "-slider": "def>==][=========<agg" }, { "-init": "1890", "-percent": "9", "-slider": "def>=][==========<agg" }, { "-init": "2190", "-percent": "0", "-slider": "def>][===========<agg" } ]
} }
the "inits": [init, percent, slider] needs within loop generate results. can statically using:
array ( 'inits' => array ( 'version' => '18.05.04_ep1', 'source' => 'live', 'lowid' => '265067', 'highid' => '265068', 'ql' => '300', 'name' => 'ofab shark mk 1', 'inits' => array ( 0 => array ( '-init' => '430', '-percent' => '100', '-slider' => 'def>===========][<agg', ), 1 => array ( '-init' => '530', '-percent' => '90', '-slider' => 'def>==========][=<agg', ), 2 => array ( '-init' => '630', '-percent' => '81', '-slider' => 'def>=========][==<agg', ), 3 => array ( '-init' => '730', '-percent' => '72', '-slider' => 'def>========][===<agg', ), 4 => array ( '-init' => '830', '-percent' => '63', '-slider' => 'def>=======][====<agg', ), 5 => array ( '-init' => '930', '-percent' => '54', '-slider' => 'def>======][=====<agg', ), 6 => array ( '-init' => '1030', '-percent' => '45', '-slider' => 'def>=====][======<agg', ), 7 => array ( '-init' => '1130', '-percent' => '36', '-slider' => 'def>====][=======<agg', ), 8 => array ( '-init' => '1290', '-percent' => '27', '-slider' => 'def>===][========<agg', ), 9 => array ( '-init' => '1590', '-percent' => '18', '-slider' => 'def>==][=========<agg', ), 10 => array ( '-init' => '1890', '-percent' => '9', '-slider' => 'def>=][==========<agg', ), 11 => array ( '-init' => '2190', '-percent' => '0', '-slider' => 'def>][===========<agg', ), ),
), )
however, have no thought how phone call methods fill in array info each array (init,percent,slider). new php, , having hard time finding right usage of php, c# developer. if can help appreciate it!
you should utilize for
. don't know want fo fill, code aso folowing:
//let $ar array have posted for($i=0;$i<count($ar["inits"]["inits"]); $i++) { $ar["inits"]["inits"][$i]["-slider"]="something"; }
php json encode
No comments:
Post a Comment