PHP actual C extension array

不言
Release: 2023-03-24 20:12:02
Original
1708 people have browsed it

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();
Copy after login




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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!