I have the following code which is generated in PHP:
<div id='container1' data-history="[["test", "test title", "", []]]">
I wish to have this accessible in javascript but when I use console.log(history[0]) it outputs '[' so its treating the array as a string.
Is there a way to have it so that javascript can read it as an array?
My PHP code is as follows (i removed the slashes and '' around the array)
echo '<div id="container1" data-history=[[0]["test", "test title", "", []]] data-current-url="'.$url.'">';
echo
for data-history attribute value from php? – Ravi Dhoriya ツ Apr 18 '14 at 7:29echo
is fine, but how are you doing that for array? plz provide php code – Ravi Dhoriya ツ Apr 18 '14 at 7:31json
, stackoverflow.com/questions/13272406/… – Ravi Dhoriya ツ Apr 18 '14 at 7:33