Question: I am not a php guy, so I have a small question for all the php devs out there. 

I am building a java application which calls a php webservice. The php web service has a login method which takes user\_auth and application\_name as parameters. user\_auth is an array which has three strings username, password and version number.

Can anyone tell me which of the below java strings match the array output when we print it?

```
1) String user = "user_auth{username=will; password=18218139eec55d83cf82679934e5cd75; version=1.0;}";
2) String user = "{'user_auth':{'username':'will','password':'18218139eec55d83cf82679934e5cd75', 'version':'1.0'}}";

```

Thanks,
aspr

Answer: 
You can any of these formats

```
$user = array('user_auth' =>
    array('username' => 'will'),
    array('password' => '18218139eec55d83cf82679934e5cd75'),
    array('version' => '1.0'),
);

var_dump(serialize($user)); // use unserialize to decode
var_dump(json_encode($user)); // use json_decode to decode

```

You any of these formats

```
String user = 'a:3:{s:9:"user_auth";a:1:{s:8:"username";s:4:"will";}i:0;a:1:{s:8:"password";s:32:"18218139eec55d83cf82679934e5cd75";}i:1;a:1:{s:7:"version";s:3:"1.0";}}' (length=153)
String user = '{"user_auth":{"username":"will"},"0":{"password":"18218139eec55d83cf82679934e5cd75"},"1":{"version":"1.0"}}' (length=107)

```
This looks like JSON (passing PHP arrays in a URL would not make much sense), but you need to use double quotes (`"`) instead of single quotes (`'`), using your second example.