I have a php multidimensional array that I am sending to jquery but I need to automatically create the array.
All the examples show setting up a manual array like so:
var theme_name = current_theme_meta.theme_name,
theme_version = current_theme_meta.version,
data0A = theme_metadata[0].dataA,
data0B = theme_metadata[0].dataB,
data1A = theme_metadata[1].dataA,
data1B = theme_metadata[1].dataB;
current_theme_meta and theme_metadata are keys in php array I built and I push to jQuery via wp_localize_script() (a wordpress function.)
theme_name, version, dataA, and dataB are key values inside the array.
My array looks like this:
[current_theme_meta] => Array
(
[theme_name] => A Cool Theme
[version] => 2.1.1
)
[theme_meta] => Array
(
[0] => Array
(
[dataA] => foo
[dataB] => bar
)
[1] => Array
(
[dataA] => this
[dataB] => that
)
)
How do I create the array in jquery? I am confused between each and loop, etc.