> $requests = array(array("test1", "test2"), array("test3", "test4"));
> my_function($requests);
>
> zval **urls;
>
> zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &urls) ==
> FAILURE)
>
> i think by trying and trying i mix up everything in my mind. may someone
> please show me how to retrieve test1, test2, test3 and test4 please ?
>
zval *urls, **innerarray, **data, copyval;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &urls) == FAILURE)
{
RETURN_FALSE;
}
/* Look through url parameter
* A la foreach($url as $innerarray)
*/
for(zend_hash_internal_pointer_reset(HASH_OF(urls);
zend_hash_get_current_data(HASH_OF(urls), (void**)&innerarray) ==
SUCCESS;
zend_hash_move_forward(HASH_OF(urls))) {
if (!innerarray || !*innerarray || Z_TYPE_PP(innerarray)) {
/* Basic sanity checking */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "One of the inner
arrays...uh...isn't an array!");
RETURN_FALSE;
}
/* Look through inner array contained in url parameter
* A la foreach($innerarray as $data)
*/
for(zend_hash_internal_pointer_reset(HASH_OF(*innerarray);
zend_hash_get_current_data(HASH_OF(*innerarray), (void**)&data) ==
SUCCESS;
zend_hash_move_forward(HASH_OF(*innerarray))) {
if (!data || !*data) {
/* Shouldn't ever *actually* happen the way a zval hash is laid
out */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This array is
wonky...");
RETURN_FALSE;
}
/* Don't change the original value, you'll confuse the scripter,
* make a copy first THEN convert to string
*/
copyval = **data;
zval_copy_ctor(©val);
convert_to_string(©val);
/* Do something with Z_STRVAL(copyval) and Z_STRLEN(copyval) */
zval_dtor(©val);
}
}
-Sara
|