The content of this article is about the array of PHP's actual C extension. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
I recently looked at the C extension writing of PHP. , try to access array processing, and learned several HashTable processing functions recorded as follows:
zend_hash_next_index_insert Insert data (numeric array or associative array);
zend_hash_add Insert associative array
zend_hash_index_update Numeric array or associative array
zend_hash_update Update associative array
Code:
zval *arr, *prefix, *entry,; zend_string *string_key; zend_ulong num_key; int a; if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa", &arr, &prefix) == FAILURE) { return; } a = zend_hash_num_elements(Z_ARRVAL_P(arr)) + zend_hash_num_elements(Z_ARRVAL_P(prefix)); array_init_size(return_value,a ); ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(arr), num_key, string_key, entry) { zend_hash_next_index_insert(Z_ARRVAL_P(return_value), entry); } ZEND_HASH_FOREACH_END();
The above is the detailed content of PHP actual C extension array. For more information, please follow other related articles on the PHP Chinese website!