Passing structure to PHP function

php.internals

Michael Spector

22 years ago
Hi, I'm "translating" some function, that recieves a pointer to structure of this type: struct { char * text; char ** value; int flags; }; and I'm get stuck here, thinking of a legal way how to pass the list of structures to my PHP function. I thought to pass it in this way: myfunc ( array( array("text" => $text1, "value" => &$value1, "flags" => flags1), array("text" => $text2, "value" => &$value2, "flags" => flags2), ... ) ); but, I wonder whether this way is acceptable? Anyway, is there another solution to this problem? Thanks.
-- Best regards, Michael

Rasmus Lerdorf

22 years ago
On Mon, 23 Aug 2004, Michael Spector wrote:
> I'm "translating" some function, that recieves a pointer to structure of > this type: > > struct { > char * text; > char ** value; > int flags; > };
This looks like a string, an array and an integer to me. So just pass that. Or an array of those if there is more than one. -Rasmus

Michael Spector

22 years ago
On Mon, Aug 23, 2004 at 11:10:16AM -0700, Rasmus Lerdorf wrote:
> On Mon, 23 Aug 2004, Michael Spector wrote: > > I'm "translating" some function, that recieves a pointer to structure of > > this type: > > > > struct { > > char * text; > > char ** value; > > int flags; > > }; > > This looks like a string, an array and an integer to me. So just pass > that. Or an array of those if there is more than one. >
Actually, the prototype of the function is the following: int newtWinEntries (char * title, char * text, int suggestedWidth, int flexDown, int flexUp, int dataWidth, struct newtWinEntry * items, char * button1, ...) Where newtWinEntry is the structure mentioned above. The problem is that I have to accept a list of such structures as an argument. Value (char ** value) is the reference to the returned value. So, you say there's no need to use string keys in the array ?
-- Best regards, Michael