使用javascript或php更改var img_列表值

使用javascript或php更改var img_列表值,javascript,jquery,Javascript,Jquery,如果 变量img_列表= [“https:\/\/img3.example.me\/upload\/511bd439da25cc716e88a2e2ac0fb3ac.jpg” ,“https:\/\/img3.example.me\/upload\/77AC7D2AB7357CA181010905B22842D.jpg” ,“https:\/\/img3.example.me\/upload\/72387065c5464e8ce92297df783a2437.jpg” ]; 有这样的东西 我

如果


变量img_列表=
[“https:\/\/img3.example.me\/upload\/511bd439da25cc716e88a2e2ac0fb3ac.jpg”
,“https:\/\/img3.example.me\/upload\/77AC7D2AB7357CA181010905B22842D.jpg”
,“https:\/\/img3.example.me\/upload\/72387065c5464e8ce92297df783a2437.jpg”
];
有这样的东西 我想把这个换成

 <script>
                var img_list = 
    ["https:\/\/img3.example.me\/upload\/511bd439da25cc716e88a2e2ac0fb3ac.jpg"
        ,"https:\/\/img3.example.me\/upload\/77ac7d2ab7357ca181010905b228842d.jpg"
        ,"https:\/\/img3.example.me\/upload\/72387065c5464e8ce92297df783a2437.jpg"
];
            </script>

变量img_列表=
[“https:\/\/img3.example2.me\/upload\/511bd439da25cc716e88a2e2ac0fb3ac.jpg”
,“https:\/\/img3.example2.me\/upload\/77ac7d2ab7357ca181010905b22842d.jpg”
,“https:\/\/img3.example2.me\/upload\/72387065c5464e8ce92297df783a2437.jpg”
];

使用
split
join
。使用
forEach
循环迭代数组,
split
分别使用
example2
join
示例中的字符串进行拆分

var img\u列表=
[“https:\/\/img3.example.me\/upload\/511bd439da25cc716e88a2e2ac0fb3ac.jpg”
,“https:\/\/img3.example.me\/upload\/77AC7D2AB7357CA181010905B22842D.jpg”
,“https:\/\/img3.example.me\/upload\/72387065c5464e8ce92297df783a2437.jpg”
];
var newlist=[];
img_list.forEach((e)=>{
newlist.push(例如split('example').join('example2');
})
img_list=newlist;

控制台日志(img_列表)
使用
split
join
。使用
forEach
循环迭代数组,
split
分别使用
example2
join
示例中的字符串进行拆分

var img\u列表=
[“https:\/\/img3.example.me\/upload\/511bd439da25cc716e88a2e2ac0fb3ac.jpg”
,“https:\/\/img3.example.me\/upload\/77AC7D2AB7357CA181010905B22842D.jpg”
,“https:\/\/img3.example.me\/upload\/72387065c5464e8ce92297df783a2437.jpg”
];
var newlist=[];
img_list.forEach((e)=>{
newlist.push(例如split('example').join('example2');
})
img_list=newlist;

控制台日志(img_列表)这两个代码段不一样吗?示例=>example2这两个代码段不一样吗?示例=>example2我可以将默认的img_列表更改为newlist吗?是的,添加example2后,可以拼接旧字符串并将新字符串添加到其中。或者你可以把新的列表和旧的列表等同起来。你能在你的文章中添加我想要的吗?我已经用同样的东西做了编辑。你也要拼接吗?我可以把默认的img_列表改成newlist吗?是的,在添加示例2后,你可以拼接旧字符串并将新字符串添加到其中。或者你可以把新的列表和旧的列表等同起来。你能在你的文章中添加我想要的吗?我已经用同样的东西做了编辑。你也要拼接的吗??
 <script>
                var img_list = 
    ["https:\/\/img3.example2.me\/upload\/511bd439da25cc716e88a2e2ac0fb3ac.jpg"
        ,"https:\/\/img3.example2.me\/upload\/77ac7d2ab7357ca181010905b228842d.jpg"
        ,"https:\/\/img3.example2.me\/upload\/72387065c5464e8ce92297df783a2437.jpg"
];
            </script>