Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php var_dump($myArray); ?>
- array (size=4)
- 'id' => string '162' (length=3)
- 'content' => string 'Test content' (length=12)
- 'children' =>
- array (size=16)
- 0 =>
- array (size=4)
- 'id' => string '29208' (length=5)
- 'content' => string 'Test content 1' (length=14)
- 'children' =>
- array (size=3)
- ...
- 1 =>
- array (size=4)
- 'id' => string '29215' (length=5)
- 'content' => string 'Test content 2' (length=14)
- 'children' =>
- array (size=1)
- ...
- 2 =>
- array (size=3)
- 'id' => string '29220' (length=5)
- 'content' => string 'Test Content 3' (length=14)
- <script type="text/javascript">
- var myVar = JSON.parse('<?php json_encode($myArray) ?>');
- </script>
- Uncaught SyntaxError: Unexpected end of input
- <script type="text/javascript">
- var x = '{"id":123,"content":"This is a test content"}';
- var myVar = JSON.parse(x);
- console.log(myVar);
- </script>
- Object
- content: "This is a test content"
- id: 123
- <?php json_encode($myArray) ?>
- <?php echo json_encode($myArray) ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement