当前位置:网站首页>往二维数组追加键值
往二维数组追加键值
2022-08-09 08:46:00 【tjg888888】
数组1:$data结构为如下:
Array
(
[0] => Array
(
[id] => 2
[jump_type] => 0
[jump_url] => 0
[content] => 亲爱的萌芽圈156****9878你的笔记正在审核中。
[created_at] => 1581393162
)
[1] => Array
(
[id] => 1
[jump_type] => 0
[jump_url] => https://www.taobao.com
[content] => 欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!
[created_at] => 1579338191
)
)
数组2:$result结构为如下:
Array
(
[nickname] => 萌芽152****9877
)
目标:将nickname键值追加到数组$data里,实现如下:
array_walk($data, function (&$value, $key, $result) {
$value = array_merge($value, $result);
}, $result);最终打印结果为如下:
Array
(
[0] => Array
(
[id] => 2
[jump_type] => 0
[jump_url] => 0
[content] => 亲爱的萌芽圈156****9878你的笔记正在审核中。
[created_at] => 1581393162
[nickname] => 萌芽152****9877
)
[1] => Array
(
[id] => 1
[jump_type] => 0
[jump_url] => https://www.taobao.com
[content] => 欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!欢迎新用户注册!
[created_at] => 1579338191
[nickname] => 萌芽152****9877
)
)
边栏推荐
猜你喜欢

QT程序生成独立exe程序(避坑版)

bs4之爬取诗词学习

PID控制电机输出作为电机PWM占空比输入的理解

Object detection app based on appinventor and EasyDL object detection API

Different styles of Flask-restful

Tencent cloud server is modified to root login to install pagoda panel

OpenHarmony Light Smart Product Development Live Notes
![[Vulnerability reproduction] CVE-2018-7490 (path traversal)](/img/0f/652869001b3e3b683192e6558d81fb.png)
[Vulnerability reproduction] CVE-2018-7490 (path traversal)

图像识别后将识别结果整理成列表,点击列表可跳转到搜索页面
![[MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause](/img/76/8e6a3a1c5fdc9bffc0c7c9187a027c.png)
[MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause
随机推荐
PoPW代币分配机制或将点燃下一个牛市
DeFi 项目中的治理Token
elder blind date
磁盘管理与挂载
网络层协议介绍
BUUCTF MISC brush notes (2)
The difference between big-endian and little-endian storage is easy to understand at a glance
图像识别后将识别结果整理成列表,点击列表可跳转到搜索页面
基于appinventor与EasyDL物体检测API的物体检测app
Boot process and service control
[MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause
[漏洞复现]CVE-2018-7490(路径遍历)
Venture DAO 行业研报:宏观和经典案例分析、模式总结、未来建议
ctf misc picture questions knowledge points
The MySQL database
How does STM32 know the usage of FLASH
100句话,是否会触动你?
monitor textbox input
数据解析之bs4学习
UE4 RTS frame selection function implementation