Posting arrays


I have to post multidimensional array with php.
Each element in the array holds 3 values

$arr = array(
array('from', 'to', 'action'),
array('from', 'to', 'action')

What would be the best way to implement this?

Would it be better to go with posting array or serializing it?
I’m not sure how else could I store 3 values for each element, beside having 3 hidden input fields for each variable: name=“variable_name” arrays

Thanks for help

How are you POST’ing these arrays?

I’m not, I’m just wondering what would be the best way to do this?

So, completely hypothetical then?


What about JSON ?

$users = array(
  array('name' => 'foo'),
  array('name' => 'bar')

echo json_encode($users);

Can you post json arrays?

It depends what your POST’ing to…

You can post anything, since everything is basically text, even JSON. As Anthony said, it depends where you’re posting it to. Since you can json_encode something, you can json_decode it if you need internal data structure such as php array at the target script.