php extension: returning array of arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jacques Lebastard

    php extension: returning array of arrays


    Hi there,

    it's my 1st week of PHP so forgive me for such a basic question. I'm
    trying to return an array of arrays of strings from a home-made PHP
    extension module. My current code looks like :

    ZEND_FUNCTION(. .)
    {
    ...
    array_init(retu rn_value);
    add_next_index_ long(return_val ue, nb_of_arrays);
    for ( ... ) {
    zval *one_array;
    array_init(one_ array);
    add_next_index_ long(one_array, nb_of_strings);
    for (...) {
    add_next_index_ string(one_arra y, string[..],1);
    }
    add_next_index_ zval(return_val ue, one_array);
    }
    }


    This causes a failure in Apache.

    Before debugging my PHP extension tomorrow morning (e.g. to suppress the
    useless '# of items' in each array ;-), can anybody tell me whether this
    is the proper way to achieve this ?

    Thx in advance,
    --
    Jacques

  • Chung Leong

    #2
    Re: php extension: returning array of arrays

    I'm pretty sure you need to call MAKE_STD_ZVAL() on a variable before
    array_init().

    Comment

    • Jacques Lebastard

      #3
      Re: php extension: returning array of arrays

      Chung Leong a écrit :[color=blue]
      > I'm pretty sure you need to call MAKE_STD_ZVAL() on a variable before
      > array_init().
      > [/color]

      It's *a lot* better. Thanks for the hint.
      --
      Jacques.

      Comment

      Working...