HI,
Not 100% sure but.

Outside of the function :
static zend_class_entry *yourclasslib_class_entry_ptr;

In the function :
object_init_ex(return_value, yourclasslib_class_entry_ptr);

add_property_zval(return_value, ...)  // array 1
add_property_zval(return_value,...) // array 2
add_property_zval(return_value,...) // array 3
add_property_stringl(return_value, "path", Z_STRVAL_PP(your_str),
Z_STRLEN_PP(your_str), 1);


your_str is zval with type string. If you want to pass string (char *) then
change Z_STRVAL_PP(your_str) with the name of the string and
Z_STRLEN_PP(your_str) with its length. The last parameter if 1 instructs the
engine to copy the strin. if 0 is not copied

Andrey

----- Original Message -----
From: "Tim" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 25, 2002 7:38 PM
Subject: [PHP-DEV] returning a bunch of arrays as fields of an object?


>
> OK, so I'm wrapping a C++ library as a PHP extension, and I want one of
> my functions to return an object that has arrays as fields of it.  I
> have created the arrays:
>
>         zval *success;
>         MAKE_STD_ZVAL(success);
>         array_init(success);
>
>         zval *score;
>         MAKE_STD_ZVAL(score);
>         array_init(score);
>
>         zval *time;
>         MAKE_STD_ZVAL(time);
>         array_init(time);
>
> and can populate them, but I'm not sure how I could return an object
> with 3 fields that are arrays, and one that is a string value.  Can
> someone point me towards further documentation?  I was confused by the
> (lack of a) similar example in the PHP book and the online
> documentation.  If there is a cleaner/more clever way to take an array
> of struct{}'s and return them as (a) PHP object/objects, and you (the
> recipients of this email) would share that with me, I would be most
> grateful.  Thanks, and sorry for what is probably a silly question.
>
>
> Thanks in advance,
>
> --tim
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to