How do I iterate through a PHP array in jQuery? I have an array in php named $viewfields
.
How do I iterate through each element of this array using jQuery?
EDIT 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'];?>");
}
If i give
$.each(arrayfromPHP,function(i,elem){
}
how do I write the code for $view['Attribute']['type'] in jQuery? elem['Attribute']['type'] won't work I suppose?
EDIT 2
elem['Attribute']['type'] does work