今天工作中碰到一个需要是先查指定数据库中是不是有满足条件的6条数据,如果没有再从B表中查找 6-A表中的数据之后再进行数组合并了,下面我来把我们整个过程给各位分享一下.
在php中合并数组我们可以使用array_merge函数
array array_merge (array array1 array2…,arrayN)
PHP实例代码如下:
- //团购1
- $t=1;
- $tugou = esf(" * "," setindex='1' $cwhere order by id desc limit 0,6","A表");
- foreach( $tugou as $v =>$_v )
- {
- $tugou[$v]['i'] =$t++;
- }
- $abpccount = count( $tugou );
- //echo $abpccount;
- if( $abpccount < 6 )
- {
- $page->tpl->assign('notg',1);//调用团购标签
- $abpclimit = 6 – $abpccount;
- $tugou_loupan = esf(" * "," index_dt='1' $cwhere order by id desc limit 0,$abpclimit ","B表");
- foreach( $tugou_loupan as $v =>$_v )
- {
- $tugou_loupan[$v]['i'] =$t++;
- $tugou_loupan[$v]['abpcindexpic'] = $_v['abpcthumb'];
- $tugou_loupan[$v]['abpclitpic'] = $_v['abpcthumb'];
- $tugou_loupan[$v]['abpcname'] = mt_rand(10,80);
- $tugou_loupan[$v]['abpcdown'] = 'xx 惠';
- $tugou_loupan[$v]['abpclpname'] = $_v['abpcname'];
- }
- $tugou = array_merge($tugou,$tugou_loupan);
- }
- $page->tpl->assign('tugou',$tugou);
注意事项:array_merge()合并时我们必须要注意一点的是中间的值必须为数组否则合并之后会返回空.
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » php合并数组array_merge函数应用实例
波比源码 » php合并数组array_merge函数应用实例
buy levaquin 250mg online order levofloxacin without prescription
avodart cost order celebrex 100mg without prescription purchase ondansetron
brand fildena 50mg buy tamoxifen 10mg generic purchase methocarbamol generic
accutane 40mg us isotretinoin 20mg price order zithromax 250mg
order anastrozole 1mg online cheap anastrozole buy online sildenafil brand
buy deltasone 20mg online cialis next day delivery overnight viagra delivery
cialis 10mg kaufen original viagra 100mg rezeptfrei sicher kaufen sildenafil 100mg generika
buy ramipril for sale order astelin 10 ml for sale astelin uk
order catapres 0.1 mg pills order meclizine 25 mg online buy spiriva 9mcg without prescription
buspar oral dilantin 100 mg generic buy oxybutynin 5mg for sale
buy alendronate 70mg online cheap order motrin without prescription purchase famotidine pill
buy generic prograf ursodiol for sale online order ursodiol 150mg pills
buy sertraline 50mg generic Generic viagra online sildenafil 100mg england
dapsone order online buy aceon 4mg aceon 4mg drug
order provigil 200mg generic buy stromectol 12mg generic stromectol tab
buy generic accutane 20mg buy accutane 20mg for sale prednisone 40mg us
buy nootropil 800 mg generic nootropil ca cheap viagra online
purchase tadalafil pills usa cialis sales purchase sildenafil generic
cheap glucophage 1000mg buy tadalafil 40mg without prescription buy tadalafil 5mg online
academic writers online help writing a paper for college play poker online free no sign up
levitra 10mg generic pregabalin cost methylprednisolone 4 mg over the counter
triamcinolone price buy clarinex 5mg generic clarinex 5mg ca
ozobax pill toradol 10mg ca toradol pill
zantac 150mg us order celecoxib online cheap purchase celecoxib
casino online games can you play poker online money online card games
zocor 20mg cost finasteride 1mg without prescription proscar order online
keflex canada order keflex 125mg generic erythromycin 250mg for sale
tadalafil pill tadalafil dosage viagra 100 mg