Home > Backend Development > PHP Tutorial > 遇到了一个JS输出的问题,求高手

遇到了一个JS输出的问题,求高手

WBOY
Release: 2016-06-20 12:42:38
Original
867 people have browsed it

我最终想要的结果是用JS输出这个

但现在四个数组分别已经输出了,就是不知道怎么能合到一起,烦请高手帮忙。
以下是分别输出的结果:


回复讨论(解决方案)

php 输出的是什么?

输出的是四个数组,数组一是所有标题,中间用逗号分开的,数组二是歌手,数组三是封面,数组四是MP3路径。

就提的样式是什么?
不知道格式怎么写代码?

jsonstr="[";for(i=0;i<new_tit.length;i++){jsonstr += "{title:\"" + new_tit[i] + "\",singer:\"" + new_singer[i] + "\",cover:\""+ new_cover[i] + "\",src:\"" + new_src[i] + "\"},";}jsonstr = jsonstr.substring(0,jsonstr.lastIndexOf(','));jsonstr += "]";
Copy after login



这样就可以组成josn格式了,自己参考一下修改吧

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template