C++ Send data to client/server



Hi. I use c ++ to load a text file into an array. (Row / column). My array looks like this:


I intend to send this data to client / server. I wonder how should I send this data so that I can then create a function in php on the client page that converts the package into an associative array in php.

I thought I might be able to send everything from c++ in json and then convert it with php on client, this would be simple to manage, but I’m not sure if this gives a std object in php? I want a default associative array (named index) when everything has been handled.

Any ideas?


ask the PHP Manual: http://php.net/json-decode


I always figured that the whole point of json-encode (which I haven’t used extensively) was that it converts the source into something that can easily be sent via HTTP, and the corresponding json-decode will revert it to the original format, so if you send a 2-d array into it, you’ll get a 2-d array out of it.

Wouldn’t it be easiest to just try it and see what arrives in the PHP code?

PHP code runs on the server, not on the client.


Of course, but when your server connects to, for example, a sql server, then your server becomes the client in this scenario (requesting from another server / application) In this case, php has no trouble handling the data that comes from this exchange back to the client(your server)