« Return to Thread: PHP arrays

PHP arrays

by Andres Gonzalez-7 :: Rate this Message:

Reply to Author | View in Thread

I am currently using SWIG to implement a PHP interface to a C/C++
application. In all of my C/C++ API functions, I simply return a
string with delimiters, for example, I would return something
like this:

sprintf(buffer, "%d\n%d\n%s\n%d", intParam1, intParam2, strParam3,
intParam3);
return buffer;

When my PHP application uses this API function, it gets a string so then
I use the following to put it in an array for use in the PHP domain:

$ret = apiFuncition();
$myArray = explode(PHP_EOL, $ret);

This is working very well, however, I now need to have my C/C++ functions
return more complex associative arrays, for example like this:

"key1"        [0] = value1
                   [1] = value2
                   [2] = value3
"key2"         [0] = value4
                   [1] = value5
"key3"         [0] = value6
                   [1] = value7

That is, an array that has an array as elements.

Does SWIG support this?  How do I format my data in the C/C++
domain so that I can get associative arrays in the PHP domain?

Thanks,

-Andres




------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: PHP arrays