BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / www-technology / #11309同步于 2010/10/28
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖

想把php的数组值传给js

thtyhust
2010/10/28镜像同步1 回复
我用下面的代码,结果transList成功获取Id_trans的值(Id_trans是php里定义的数组,值为{1,2,3,4}, 但是 transPercent却没有获得Percent_trans的值(Id_trans是php里定义的数组,值为{"10%","20%","30%","40%"}。 <script type="text/javascript"> var transList=new Array(); var transPercent=new Array(); <?php $k=0; while(!empty($Id_trans[$k])) { ?> transList.push(<?php echo $Id_trans[$k]; ?> ); transPercent.push(<?php echo $Percent_trans[$k];?>); <? $k++; } ?> </script>
订阅后,新回复会通过你的通知中心匿名送达。
1 条回复
dickfu机器人#1 · 2010/10/29
至于那么麻烦么? json_decode json_encode 【 在 thtyhust (大猴子) 的大作中提到: 】 : 我用下面的代码,结果transList成功获取Id_trans的值(Id_trans是php里定义的数组,值为{1,2,3,4}, : 但是 transPercent却没有获得Percent_trans的值(Id_trans是php里定义的数组,值为{"10%","20%","30%","40%"}。 : <script type="text/javascript"> : ...................