By using var_dump($_POST);, I'm getting the following output:

    ["data"] => array(2) 
        ["title"] => "XXX"
        ["server"] => "XXXXXX"
    ["Itemid"] => "101"

My aim is to get the server value. I can easily achieve this by using:


Having snooped around, I found that using the following can be used:

$array  = $input->post->getArray(array());      
$server = $array['data']['server'];

Is this the best approach for JInput or is there something better?


2 Answers 2


This should work:

$values = $app->input->getArray(array('data'=>'array'));
echo $values['data']['server'];

Please see I did not mention post variable specifically, because this can retrieve both get and post values. If you need to get a value from a specific super global, such as post, you can use something like $app->input->post

You can retrieve multiple values by passing their names and data type in above format. This way you can get exactly what you want instead of getting raw data which is potentially not safe. Always mention the data type that you require.


You could try:

$data = $input->post->get('data', array(), 'ARRAY');
$server = $data['server'];

Haven't a playground to test this in, but I think it works.

  • Isn't this method used in an older version of the platform?
    – Lodder
    Commented Jun 2, 2015 at 15:58
  • Not 100% sure, but the method is in the current source, since 11.1, with no deprecated notice. Commented Jun 2, 2015 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.