php内置函数分析之array_change_key_case()
PHP_FUNCTION(array_change_key_case)
{
zval *array, *entry;
zend_string *string_key;
zend_string *new_key;
zend_ulong num_key;
zend_long change_to_upper=; if (zend_parse_parameters(ZEND_NUM_ARGS(), "a|l", &array, &change_to_upper) == FAILURE) {
return;
} array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL_P(array))); ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_key, string_key, entry) {
if (!string_key) { // 数组键值为数字索引,将数组元素更新到return_value
entry = zend_hash_index_update(Z_ARRVAL_P(return_value), num_key, entry);
} else { // 数组键值为字符串
// 字符串键值大小写转换
if (change_to_upper) {
new_key = php_string_toupper(string_key);
} else {
new_key = php_string_tolower(string_key);
}
// 将数组元素更新到return_value
entry = zend_hash_update(Z_ARRVAL_P(return_value), new_key, entry);
// 释放zend_string, 如果引用数位0,则释放内存。
zend_string_release(new_key);
}
// 增加引用
zval_add_ref(entry);
} ZEND_HASH_FOREACH_END();
}
php内置函数分析之array_change_key_case()的更多相关文章
- map内置函数分析所得到的思路
map:会根据提供的函数对指定序列做映射. map(func, *iterables) --> map object Make an iterator that computes the fun ...
- php内置函数分析之array_diff_assoc()
static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_type) /* {{{ */ { uint ...
- php内置函数分析之array_combine()
PHP_FUNCTION(array_combine) { HashTable *values, *keys; uint32_t pos_values = ; zval *entry_keys, *e ...
- php内置函数分析之ucwords()
PHP_FUNCTION(ucwords) { zend_string *str; char *delims = " \t\r\n\f\v"; register char *r, ...
- php内置函数分析之strtoupper()、strtolower()
strtoupper(): PHP_FUNCTION(strtoupper) { zend_string *str; ZEND_PARSE_PARAMETERS_START(, ) Z_PARAM_S ...
- php内置函数分析之ucfirst()、lcfirst()
ucfirst($str) 将 str 的首字符(如果首字符是字母)转换为大写字母,并返回这个字符串. 源码位于 ext/standard/string.c /* {{{ php_ucfirst Up ...
- php内置函数分析之trim()
官方手册中: 类似函数还有两个:ltrim() 和 rtrim().分别处理字符串的左侧.右侧. trim()的具体实现位于:ext/standard/string.c /* {{{ proto st ...
- php内置函数分析之str_pad()
PHP_FUNCTION(str_pad) { /* Input arguments */ zend_string *input; /* Input string 输入字符串*/ zend_long ...
- php内置函数分析之array_fill_keys()
PHP_FUNCTION(array_fill_keys) { zval *keys, *val, *entry; if (zend_parse_parameters(ZEND_NUM_ARGS(), ...
随机推荐
- 【c++进阶:c++ 顺序容器vector,string,deque,list,forward_list,array常用性质】
常用5种顺序容器性质: https://blog.csdn.net/oil_you/article/details/82821833 关于deque https://www.cnblogs.com/L ...
- node_modules .bin文件夹下的文件
node_modues/.bin文件夹下,对于一个npm包,有两个可执行文件,没有后缀名的是是对应unix系的shell脚本,.cmd文件对应的是windows bat脚本,内容都是用node执行一个 ...
- 阶段3 1.Mybatis_11.Mybatis的缓存_5 缓存的概念
2.Mybatis中的缓存 什么是缓存 存在于内存中的临时数据. 为什么使用缓存 减少和数据库的交互次数,提高执行效率. 什么样的数据能使用缓存 ...
- gitlab在centos7.3上搭建
gitlab在centos7.3上搭建 最近接到gitlab+jenkins的任务,由于以前只接触过GitHub,并只是简单的使用,这里简单记录gitlab与jenkins搭建的 环境: centos ...
- pgAdmin III 使用图解
pgAdmin III简介 要打开一个到服务的连接,在树中选择所需的服务,并双击它,或使用“工具”菜单上的连接即可. 一.主窗体 在主窗口中,显示数据库的结构.您可以创建新的对象,删除和编辑现有的对象 ...
- 【MM系列】SAP MM模块-关于批次特性的查看和获取
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-关于批次特性的查看 ...
- Scratch少儿编程系列:(一)版本的选择及安装
工欲善其事必先利其器,为了使用Scratch,首先要到官网上下载相关软件. 官网链接地址为:https://scratch.mit.edu/download,我用的是Windows系统,下载对应的安装 ...
- 20191112 Spring Boot官方文档学习(4.3)
4.3.Profiles Spring Profiles提供了一种隔离部分应用程序配置并使之仅在某些环境中可用的方法.任何@Component,@Configuration或@Configuratio ...
- 分享一个linux系统中循环遍历两个数组内容,并输出数组中的不同内容的shell脚本
cat diffarray.sh #!/bin/bash arry_list1=(1 2 3 4 5 6 7 8 9) arry_list2=(3 5 8) declare -a diff_list ...
- [知乎]自己真是Know Nothing 历史上有哪些细思恐极的事件?
作者:敖让链接:https://www.zhihu.com/question/38374479/answer/652432284来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...