Vinsens
Vinsens

Reputation: 199

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):

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

And I got like

enter image description here

what happen? why the result is 1 ?

It's possible to echo to a form in array format?

Upvotes: 0

Views: 128

Answers (1)

Amit Rajput
Amit Rajput

Reputation: 2059

Just pass the 2nd parameter true like below:

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

For your help: http://php.net/manual/en/function.print-r.php

Hope this will useful.

Upvotes: 1

Related Questions