Reputation: 1129
How to create an associative javascript/jquery array of this php structure:
$array = array(
'index' => array(
'subindex' => 'default',
'subindex' => 'default'
),
'index2' => array(
'subindex2' => 'default',
'subindex2' => 'default'
)
);
Thanks!
Upvotes: 2
Views: 1121
Reputation: 455
like this
<script type="text/javascript">
var anArray = [
{"index":[
{"subindex":"default"},
{"subindex":"default"}
]},
{"index2":[
{"subindex":"default"},
{"subindex2":"default"}
]}
];
</script>
Upvotes: 1
Reputation: 56587
var a = {
'index': {
'subindex1': 'default',
'subindex2': 'default'
},
'index2': {
'subindex1': 'default',
'subindex2': 'default'
}
};
Upvotes: 5