Like the title
For example, what I want to achieve is that I pass an array through the tp framework and I want to turn it into an array object
var data = [];
var countObj ={};
var tagNumObj ={};
for (var i = 0; i < 7; i ) {
var count = {$tagGroupArray[i]['count']};
var tagName = "{$tagGroupArray[i]['tagName']}";
countObj = {'count':count};
tagNumObj = {'tagName':tagName};
data[i] = countObj;
data[i] = tagNumObj;
}
console.log(data);
This is how it is displayed
var count = ;
var tagName = "";
countObj = {'count':count};
tagNumObj = {'tagName':tagName};
data[i] = countObj;
data[i] = tagNumObj;
If the above is written like this
for (var i = 0; i < 7; i ) {
var count = {$tagGroupArray[0]['count']};
var tagName = "{$tagGroupArray[0]['tagName']}";
countObj = {'count':count};
tagNumObj = {'tagName':tagName};
data[i] = countObj;
data[i] = tagNumObj;
}
This is how it is displayed
var count = 8;
var tagName = "Hello";
countObj = {'count':count};
tagNumObj = {'tagName' :tagName};
data[i] = countObj;
data[i] = tagNumObj;
It means that i is not obtained, but how to get this i? Please answer. Or is there any other way to convert an ordinary array into a js array object? That’s fine. I’d like to ask sincerely
Convert array to json format
If it is template assignment, use PHP to loop directly
If it is an interface to obtain the value, use json directly