【发布时间】:2010-11-15 09:47:37
【问题描述】:
如何在 jQuery 中遍历 PHP 数组?我在 php 中有一个名为 $viewfields 的数组。
如何使用 jQuery 遍历这个数组的每个元素?
编辑 1
<?php foreach ($viewfields as $view): ?>
if(<?=$view['Attribute']['type'];?>=='text'||<?=$view['Attribute']['type'];?>=='number')
{
$("<input id=input<?=$view['Attribute']['sequence_no'];?> type= 'text' style= 'width:<?=$view['Attribute']['size'];?>px' data-attr=<?=$view['Attribute']['type'];?> ></input><br>").appendTo("#fb_contentarea_col1down21 #<?=$view['Attribute']['sequence_no'];?>");
}
如果我给了
$.each(arrayfromPHP,function(i,elem){
}
如何在 jQuery 中编写 $view['Attribute']['type'] 的代码? 我想 elem['Attribute']['type'] 不起作用?
编辑 2
elem['Attribute']['type'] 确实有效
【问题讨论】: