Home > Backend Development > PHP Tutorial > A compilation of array operations in zend

A compilation of array operations in zend

WBOY
Release: 2016-07-29 08:58:11
Original
1167 people have browsed it
The value of the array is stored in the zvalue_value.ht field, ht is the data of a HashTable
In the Zend/zend_vm_execute.h file
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
  zend_op * opline = EX(opline);
array_init( &EX_T(opline->result.u.var).tmp_var); //Allocate array memory space, initialize
if (IS_CV == IS_UNUSED) {
ZEND_VM_NEXT_OPCODE();
#if 0 || IS_CV != IS_UNUSED
} else {
                                                                                                         ,,,,,,,,,,,,,,,,,,,,,,, zval *arg, uint size ZEND_FILE_LINE_DC) /* {{{ */
{
  ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg );
}
Did you see it, Hash Table initialization function_zend_hash_init
In PHP expansion, we can write this way:
Php_function (test) {
zval *value;
make_std_zval (value);
Array_init (Value);


T_SYMBOL (EG (Active_symbol_table), "STAR" , value);
Add the key code of an element
add_assoc_long(zval *array, char *key, long n); Add a long integer element.
add_assoc_unset(zval *array, char *key); Add an unset element.
add_assoc_bool(zval *array, char *key, int b); Add a Boolean value.
add_assoc_resource(zval *array, char *key, int r); Add a resource.
add_assoc_double(zval *array, char *key, double d); Add a floating point value.
add_assoc_string(zval *array, char *key, char *str, int duplicate); Add a string. duplicate is used to indicate whether this string should be copied to Zend's internal memory.
add_assoc_stringl(zval *array, char *key, char *str, uint length, int duplicate); Add a string of specified length.
add_assoc_zval(zval *array, char *key, zval *value); Add a zval structure.
add_index_long(zval *array, uint idx, long n); Add a long integer element.
add_index_unset(zval *array, uint idx); Add an unset element.
add_index_bool(zval *array, uint idx, int b); Add a Boolean value.
add_index_resource(zval *array, uint idx, int r); Add a resource.
add_index_double(zval *array, uint idx, double d); Add a floating point value.
add_index_string(zval *array, uint idx, char *str, int duplicate);
Add a string. duplicate is used to indicate whether this string should be copied to Zend's internal memory.
add_index_stringl(zval *array, uint idx, char *str, uint length, int duplicate); Add a string of specified length.
add_index_zval(zval *array, uint idx, zval *value); Add a zval structure.
add_next_index_long(zval *array, long n); Add a long integer element.
add_next_index_unset(zval *array); Add an unset element.
add_next_index_bool(zval *array, int b); Add a Boolean value.
add_next_index_resource(zval *array, int r); Add a resource.
add_next_index_double(zval *array, double d); Add a floating point value.
add_next_index_string(zval *array, char *str, int duplicate); Add a string. duplicate is used to indicate whether this string should be copied to Zend's internal memory.
add_next_index_stringl(zval *array, char *str, uint length, int duplicate); Add a string of specified length.
add_next_index_zval(zval *array, zval *value); Add a zval structure. Add another array, object or stream of data.



The above is an introduction to the array operations in zend, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.


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