Advertisement
GlobHeal

Untitled

Jan 16th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. <?php
  2.     $ar = array('01\21\2018' => '2', '01\22\2018' => '3', '01\18\2018' => '6', '01\26\2018' => '4');
  3.     $json = json_encode($ar);
  4.     echo $json;
  5.     $json_array  = json_decode($json, true);
  6.     $elementCount  = count($json_array);
  7. ?>
  8.  
  9. <script type="text/javascript">
  10.     var json = <?php echo $json; ?>;
  11.     var length = <?php echo $elementCount; ?>;
  12.     console.log(json);
  13.     console.log(length);
  14.     for(var i = 0; i < length; i++) {
  15.         var obj = json[i];
  16.         console.log(obj);
  17.     }
  18. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement