0

Here is some PHP code:

$map[1][3]['test'][0]='weee';
$map[4][5]['test'][0]='bleh';
$map[1][3]['bleh'][0]='mooo';
$map[1][3]['bleh'][1]='baaa';
echo "map = " . json_encode($map) . ";";

How do I access these items in Javascipt?

I've tried all sorts:

map[1][3]['bleh'][1]
map[1][3].bleh[1]
map.1.3.bleh[1]

but nothing seems to work :(

Thanks!

1
  • 1
    map[1][3]['bleh'][1] works fine for me. Scope issues? Commented Dec 3, 2010 at 4:09

1 Answer 1

1

Works for me, except for your last one

<html>
<body>
<script type="text/javascript">
<?php

$map[1][3]['test'][0]='weee';
$map[4][5]['test'][0]='bleh';
$map[1][3]['bleh'][0]='mooo';
$map[1][3]['bleh'][1]='baaa';

print "map = ".json_encode($map).";\n";
?>

alert(map[1][3]['bleh'][1]);
alert(map[1][3].bleh[1]);

</script>
</body>
</html>
Sign up to request clarification or add additional context in comments.

2 Comments

Hmm yes, my example does work, I should have checked haha! Sorry... will investigate further
Turns out the issue was caused by lack of casting when creating the initial array using simplexml! What a headache haha

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.