Returning an array is a little bit more complex. Here we take
a string and a count and return an array with the specified
number of elements containing the given string.
So, to return an array you first call array_init() on the return_value zval
and then populate the array by calling the various add_* functions. The
functions available to populate an array are:
Recall that PHP supports the non-indexed array syntax. eg.
This same concept is available in the extension API using these functions:
You can also create an array with non-numeric indices. Otherwise known as an
associative array using these functions:
To return a 2-dimensional array, you simply make new arrays and add them as
elements of the top array. Like this:
Note the use of add_assoc_long_ex() in the above example. If
we know the length of the key, then this is slightly faster than calling
add_assoc_long(). The macro definition shows why: