Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $data=array(
- "61" => array("sku"=>"a","unit_price"=>"1.0000","supplier_id"=>"61","sku_id"=>"7"),
- "62" => array("sku"=>"b","unit_price"=>"2.0000","supplier_id"=>"62","sku_id"=>"3"),
- "63" => array("sku"=>"c","unit_price"=>"3.0000","supplier_id"=>"63","sku_id"=>"4"),
- "64" => array("sku"=>"d","unit_price"=>"4.0000","supplier_id"=>"64","sku_id"=>"10"),
- "65" => array("sku"=>"e","unit_price"=>"5.0000","supplier_id"=>"65","sku_id"=>"9"),
- "66" => array("sku"=>"f","unit_price"=>"6.0000","supplier_id"=>"66","sku_id"=>"2"),
- "59" => array("sku"=>"g","unit_price"=>"7.0000","supplier_id"=>"59","sku_id"=>"11"),
- "67" => array("sku"=>"h","unit_price"=>"8.0000","supplier_id"=>"67","sku_id"=>"5"),
- "68" => array("sku"=>"i","unit_price"=>"9.0000","supplier_id"=>"68","sku_id"=>"8"),
- "69" => array("sku"=>"j","unit_price"=>"10.0000","supplier_id"=>"69","sku_id"=>"6"),
- "70" => array("sku"=>"k","unit_price"=>"11.0000","supplier_id"=>"70","sku_id"=> "1")
- );
- $json=json_encode($data);
- ?>
- <!DOCTYPE html>
- <head>
- <title>Latihan JSON</title>
- <head>
- <body>
- <script>
- var sumber=<?php echo $json;?>;
- function getData(index)
- {
- return sumber[index];
- }
- var data=getData("66");
- alert(data['sku']+"--"+data['unit_price']+"--"+data['supplier_id']+"--"+data['sku_id']);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement