php-app开发接口加密的示例分析
249
2022-10-31
php 数组一维按key拆分和替换二维数组的key
/* * a 需要处理的数组 * keywords 被替换的文字 */function subOrderSearch($a,$keywords) { $arr=$result=array(); foreach ($a as $key => $value) { if(strstr($key, $keywords) !== false) { array_push($arr, $value); } } //拆分一份数组为二维 $chunk_result = array_chunk($arr,10); //替换二维数组的子数组的key $key_name = ['overload',"oversize","case_number","order_sn_son","package_long","package_heigh","package_width","package_volume","package_gross_wait","single_billable_weight"]; foreach ($chunk_result as $k => $v) { $chunk_result[$k] = array_combine($key_name,$v); } return $chunk_result;}
调用
$data = [];keywords= "suborder-";//被替换的值$subOrderSearch = subOrderSearch($data,$keywords);
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~