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'
    ); ?> 


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:

    [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.