0

I'm totally new to php. I'm trying to echo the value of an input field into a an array but it doesn't seem to work.e.g echo the value of hidden-input as the value for origin in the array. How can I achieve this.

<form method="post"> <input id="hidden-input" name="from[]" value=""> </form> <?php 


    $params = array(
        'origin'        =>  $_POST['from'],
        'destination'   => um_user('postal_zip_code'),
        'sensor'        => 'true',
        'units'         => 'imperial'
    ); ?> 
2
Contributors
1
Reply
9
Views
2 Years
Discussion Span
Last Post by cereal
0

Hi,

to hide an input field use type="hidden":

<input type="hidden" name="from[]">

Now, $_POST['from'] will be an array, if value is not assigned, then it will be an empty array, for example:

Array
(
    [origin] => Array
        (
            [0] => 
        )

    [other] => hey
)

So, if you have a problem with it, how are you trying to access his values? You cannot directly echo an array, you can implode it to a string, use serialization, or json encode, or you can loop it to read each single value. This can help you:

And if you're still in doubts, share the code that does not work.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.