当前位置:网站首页>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
边栏推荐
- Summary of wrong questions 1
- 高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
- Easy to understand subset DP
- RSA encryption and decryption signature verification
- 如何实现根据照片获取地理位置及如何防御照片泄漏地理位置
- Example of data object mask used by SAP translate
- SAP 101K 411k inventory change
- Go language learning notes - slice, map | go language from scratch
- [reading notes] Chapter 5 conditional statements, circular statements and block statements of Verilog digital system design tutorial (with answers to thinking questions)
- Flutter's loading animation is more interesting
猜你喜欢
随机推荐
Where is int a = 1 stored
112. Path sum
Example of data object mask used by SAP translate
1 + X cloud computing intermediate -- script construction, read-write separation
LeetCode 1611. The minimum number of operations to make an integer 0
ES-aggregation聚合分析
108. Convert an ordered array into a binary search tree
MySQL of database -- overview and installation
SAP pi / PO soap2proxy consumption external WS example
Codeforces Round #784 (Div. 4)
机器学习(六)——贝叶斯分类器
Machine learning (VI) -- Bayesian classifier
DVWA range practice record
501. Mode in binary search tree
Unfortunately, I broke the leader's confidential documents and spit blood to share the code skills of backup files
MySQL of database -- Fundamentals
三、6【Verilog HDL】基础知识之门级建模
Personal homepage software fenrus
Setnx command execution failed due to full redis memory
错题汇总1









![Sql1 [geek challenge 2019]](/img/ad/afca09bc1da003393319af700e90e3.png)