当前位置:网站首页>php 二维数组指定元素相等后相加否则新增
php 二维数组指定元素相等后相加否则新增
2022-04-23 09:37:00 【亚历山大海】
$pr_prduct = array();
$pr_prduct_or = explode(',', Dakuohao($rs["pin_ren_order"], false));
$ij = 0;
for ($or = 0; $or < count($pr_prduct_or); $or++) {
$sqllist = "select * from shop_list where orderid=" . $pr_prduct_or[$or] . " ";
$arrlist = _get_all($sqllist);
foreach ($arrlist as $ilist => $rslist) {
$demo = array_search($rslist["p_id"], array_column($pr_prduct, 'p_id'));//和库中对比,存在相加,不存在新增
if (is_numeric($demo)) {
$pr_prduct[$demo]["productnum"] += $rslist["productnum"];
} else {
$pr_prduct[$ij]["p_id"] = $rslist["p_id"];
$pr_prduct[$ij]["productnum"] = $rslist["productnum"];
$ij++;
}
}
}
版权声明
本文为[亚历山大海]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_44936767/article/details/124284237
边栏推荐
- SAP pi / PO function operation status monitoring and inspection
- Leetcode question bank 78 Subset (recursive C implementation)
- Where is int a = 1 stored
- 亚马逊云科技入门资源中心,从0到1轻松上云
- Go language learning notes - structure | go language from scratch
- Enter "net start MySQL" and "system error 5. Access denied" appears. Detailed explanation of the problem
- Setnx command execution failed due to full redis memory
- Node installation
- Three ways to create objects in JS
- JSON input of Chapter 14 of kettle paoding jieniu
猜你喜欢
Go language learning notes - exception handling | go language from scratch
Acquisition of DOM learning elements JS
Redis 内存占满导致的 Setnx 命令执行失败
653. Sum of two IV - input BST
Summary of wrong questions 1
501. Mode in binary search tree
Exclusive thoughts and cases of JS
Kettle实验 (三)
Principle of synchronized implementation
Secrets in buffctf file 1
随机推荐
RSA 加密解密签名验签
Learn FPGA (from Verilog to HLS)
Three ways to create objects in JS
【SQL server速成之路】数据库的视图和游标
Unfortunately, I broke the leader's confidential documents and spit blood to share the code skills of backup files
Buuctf [actf2020 freshman competition] include1
AI上推荐 之 MMOE(多任务yyds)
Simply understand = = and equals, why can string not use new
JS and how to judge custom attributes in H5
亚马逊云科技入门资源中心,从0到1轻松上云
SAP pi / PO function operation status monitoring and inspection
Go language learning notes - array | go language from scratch
MacOS下使用CLion编译调试MySQL8.x
npm ERR! network
RSA encryption and decryption signature verification
MySQL of database -- overview and installation
Kernel PWN learning (3) -- ret2user & kernel ROP & qwb2018 core
Operation not allowed for a result set of type resultset TYPE_ FORWARD_ ONLY. Explain in detail
Leetcode0587. 安装栅栏(difficult)
《数字电子技术基础》3.1 门电路概述、3.2 半导体二极管门电路