1. PHP_FUNCTION(array_fill_keys)
  2. {
  3. zval *keys, *val, *entry;
  4.  
  5. if (zend_parse_parameters(ZEND_NUM_ARGS(), "az", &keys, &val) == FAILURE) {
  6. return;
  7. }
  8.  
  9. /* Initialize return array */
  10. array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL_P(keys)));
  11.  
  12. // 遍历数组keys
  13. ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), entry) {
  14. ZVAL_DEREF(entry);
  15. Z_TRY_ADDREF_P(val);
  16. /* 以数组key值为键,val为值。插入返回的数组return_value */
  17. if (Z_TYPE_P(entry) == IS_LONG) {
  18. zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL_P(entry), val);
  19. } else {
  20. zend_string *key = zval_get_string(entry);
  21. zend_symtable_update(Z_ARRVAL_P(return_value), key, val);
  22. zend_string_release(key);
  23. }
  24. } ZEND_HASH_FOREACH_END();
  25. }

php内置函数分析之array_fill_keys()的更多相关文章

  1. map内置函数分析所得到的思路

    map:会根据提供的函数对指定序列做映射. map(func, *iterables) --> map object Make an iterator that computes the fun ...

  2. php内置函数分析之array_diff_assoc()

    static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_type) /* {{{ */ { uint ...

  3. php内置函数分析之array_combine()

    PHP_FUNCTION(array_combine) { HashTable *values, *keys; uint32_t pos_values = ; zval *entry_keys, *e ...

  4. php内置函数分析之ucwords()

    PHP_FUNCTION(ucwords) { zend_string *str; char *delims = " \t\r\n\f\v"; register char *r, ...

  5. php内置函数分析之strtoupper()、strtolower()

    strtoupper(): PHP_FUNCTION(strtoupper) { zend_string *str; ZEND_PARSE_PARAMETERS_START(, ) Z_PARAM_S ...

  6. php内置函数分析之ucfirst()、lcfirst()

    ucfirst($str) 将 str 的首字符(如果首字符是字母)转换为大写字母,并返回这个字符串. 源码位于 ext/standard/string.c /* {{{ php_ucfirst Up ...

  7. php内置函数分析之trim()

    官方手册中: 类似函数还有两个:ltrim() 和 rtrim().分别处理字符串的左侧.右侧. trim()的具体实现位于:ext/standard/string.c /* {{{ proto st ...

  8. php内置函数分析之str_pad()

    PHP_FUNCTION(str_pad) { /* Input arguments */ zend_string *input; /* Input string 输入字符串*/ zend_long ...

  9. php内置函数分析range()

    PHP_FUNCTION(range) { zval *zlow, *zhigh, *zstep = NULL, tmp; , is_step_double = ; double step = 1.0 ...

随机推荐

  1. JavaScript函数、BOM

    [函数的声明和调用] 1.>>>函数声明的格式:形参可以不用var声明 使用function关键字声明: function 函数名 (参数1,参数2,......){ //函数体 r ...

  2. zstack分配的虚拟机的dns设置

    环境: $ uname -a Linux 10-57-19-61 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x8 ...

  3. 【HANA系列】SAP HANA Studio出现"Fetching Children..."问题

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP HANA Studio出 ...

  4. 【Unity Shader】---数据类型和关键字

    一.基本数据类型:Cg支持7种基本的数据类型 1.float,32位浮点数据,一个符号位.浮点数据类型被所有的图形接口支持: 2.half,16位浮点数据: 3.int,32位整形数据 4,fixed ...

  5. vim加脚本注释和文本加密

    vim /etc/vimrc 一.李导版本 autocmd BufNewFile *.py,*.cc,*.sh,*.java exec ":call SetTitle()" fun ...

  6. DB.JDBC_jar_下载

    1.Download Microsoft JDBC Driver for SQL Server - SQL Server _ Microsoft Docs.html(https://docs.micr ...

  7. MySQL的count(*)性能怎么样?

    对于count(主键id)来说,innodb引擎会遍历整张表,把每一行的id值都取出来,返回给server层,server层判断id值不为空,就按行累加 对于count(1)来说,innodb引擎遍历 ...

  8. [Python3] 004 字符串的基本使用

    目录 1. 字符串简介 1.1 作用 1.2 注意点 2. 使用方式 2.1 用引号括起来 少废话,上例子 2.2 单.双引号可以"轮换交替" 少废话,上例子 3. 转义字符 3. ...

  9. Java中的四种权限修饰符

    权限修饰符   public protected [default] private 同一个类 YES YES YES YES 同一个包 YES YES YES NO 不同包子类 YES YES NO ...

  10. 动态规划: HDU1003Max Sum

    Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...