简体   繁体   English

PHP-将数组数据回显到form_input

[英]PHP - Echo an array data to form_input

How to echo an array to a form? 如何将数组回显到表单?

My array 我的数组

Array
(
    [0] => Array
        (
            [id] => item1
            [price] => 300
            [quantity] => 1
        )
    [1] => Array
        (
            [id] => item2
            [price] => 400
            [quantity] => 2
        )
)

I tried like (codeigniter): 我试过像(codeigniter):

echo form_textarea('detail_prod',print_r($detail));

And I got like 我得到

在此处输入图片说明

what happen? 发生什么事? why the result is 1 ? 为什么结果是1?

It's possible to echo to a form in array format? 是否有可能以数组格式回显表单?

Just pass the 2nd parameter true like below: 只需将第二个参数传递为true如下所示:

echo form_textarea('detail_prod',print_r($detail, true));

For your help: http://php.net/manual/en/function.print-r.php 为您提供帮助: http : //php.net/manual/zh/function.print-r.php

Hope this will useful. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM