How To Post 3D Array In Yii


Iam a newbie in yii i need to post a 3-d array how it can be done any suggestions.?? plz plz :blink: :blink:

Well, ask yourself how you would do it in PHP.

If you have the following html field name in your form : “3darray[i][j][k]”, and you submit its value through post method, you’ll catch it in $_POST[‘3darray’][i][j][k].

Indeed, this is not Yii stuff.

Thanks Sir for reply… My problem is a little bit complicated …

Here is snap of my code in view



           foreach($menu as $item)




               $amount += $item['price'];



And then displaying data on page using foreach...




                <td class="number"><?php echo $products[$x][0]; ?></td>

                <td class="name"><?php echo $products[$x][2];?></td>

                <td class="Type"><?php echo $products[$x][4] ;?></td>

                <td class="day"><?php echo $products[$x][1] ;?></td>

                <td class="Topings"><?php echo $products[$x][1] ;?></td>

                <td class="price"><?php echo $products[$x][3]; ?></td>


Problem is iam not able to post this variable($product) to another controller’s view so their i can do some other stuff… i tried making a form hidden field and sending data through it… but it says can not convert arry into string.

Then you have probably tried to pass an array to CHtml.hiddenField(). You will need to unroll that as well.

As a side note: You should always pass values through CHtml.encode() before displaying them in views.

Thanks Sir, It working now…