本文章这里是一个己排序好的二维数据,我们要向数组中插入一个元素这个保存到数据中后还需要进行排序的哦,代码如下:
- <?php
- /**
- * 逆序二维数组插入一元素
- *
- * @author WadeYu
- * @date 2012-05-30
- */
- $aSorted = array(
- array(1, 100),
- array(2, 90),
- array(3, 80),
- array(4, 70),
- array(5, 60),
- array(6, 50),
- array(7, 40),
- array(8, 40),
- array(9, 40),
- array(10, 20),
- );
- $aInsert = array(11, 40);
- $maxCmpIdx = 0;
- $cnt = 0;
- $maxCnt = 10;
- foreach ($aSorted as $idx => $arr){
- if ($arr[0] == $aInsert[0]){
- $maxCmpIdx = $idx;
- }
- $cnt++;
- }
- if ( !$maxCmpIdx){
- $maxCmpIdx = $cnt++;
- }
- $aSorted[$maxCmpIdx] = $aInsert;
- for ($i = $maxCmpIdx; $i > 0; $i–){
- if ($aSorted[$i][1] > $aSorted[$i-1][1]){
- $aTmp = $aSorted[$i-1];
- $aSorted[$i-1] = $aSorted[$i];
- $aSorted[$i] = $aTmp;
- continue ;
- }
- break;
- }
- for ($i = $cnt; $i > $maxCnt; $i–){
- unset($aSorted[$i-1]);
- }
- print_r($aSorted);
在数组中插入元素的方法有很多,这里只介绍了一种,有需要了解更多的朋友可到本站搜索。
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » php中向数组中插入一元素程序代码
波比源码 » php中向数组中插入一元素程序代码
levofloxacin 500mg pill order levaquin 250mg online
purchase avodart generic celebrex 200mg ca ondansetron oral
spironolactone 25mg brand valacyclovir cost fluconazole 200mg oral
oral ampicillin 500mg buy generic bactrim 960mg erythromycin 250mg canada
sildenafil generic buy nolvadex 20mg for sale robaxin 500mg without prescription
order suhagra 50mg online cheap cost aurogra order estradiol sale
lamictal 200mg without prescription purchase tretinoin tretinoin gel tablet
order tadalafil 20mg pill tadalis ca oral voltaren 100mg
order accutane 20mg pill cheap amoxil generic zithromax 500mg uk
cialis 40mg Generic viagra in canada viagra 50mg uk
buy generic arimidex Buy branded viagra order sildenafil 100mg generic
buy modafinil 100mg Best price cialis acetazolamide 250mg over the counter
buy doxycycline pills order levitra 20mg sale furosemide pills
catapres 0.1mg oral purchase minocin online buy spiriva 9 mcg without prescription
buy hytrin 1mg online azulfidine online buy order azulfidine 500 mg pills
fosamax 70mg tablet order panadol 500 mg online pepcid 20mg drug
purchase imdur generic buy azathioprine 25mg sale telmisartan 20mg ca
buy molnunat 200mg generic lansoprazole ca lansoprazole 30mg oral
sertraline 50mg oral order generic zoloft 50mg sildenafil medication
tadalafil for sale Cialis for order viagra ca
cialis tadalafil 40mg buy cialis 20mg for sale symmetrel 100mg brand
luvox 50mg generic glucotrol 5mg usa buy glucotrol 10mg online
isotretinoin 10mg pill order prednisone 40mg without prescription prednisone 5mg pills
nootropil over the counter order viagra generic sildenafil 150mg
order tadalafil 5mg online cheap order betnovate 20 gm sale purchase anafranil generic
chloroquine pill generic aralen baricitinib medication
sporanox over the counter buy itraconazole 100mg buy tindamax 500mg online
glucophage 500mg drug glucophage pill cialis pills 20mg
buy zyprexa 10mg pill nebivolol 5mg over the counter buy diovan 80mg online
purchase amlodipine pill order sildenafil 50mg for sale order tadalafil online cheap
clozapine canada generic combivent order decadron pills
linezolid 600mg us play blackjack casino games online best online casino for real money
omeprazole 10mg pills buy custom research paper poker online for real money
buy generic metoprolol generic metoprolol vardenafil over the counter
affordable term papers black jack card game free online casinos for real money
help write my paper academic writing services uk purchase sildenafil pill
cialis next day cialis 40mg usa order viagra 100mg generic
cheap triamcinolone clarinex price desloratadine price
buy priligy 90mg generic buy generic dapoxetine 60mg synthroid 100mcg uk
xenical cheap buy acyclovir zovirax 400mg sale
order cialis 10mg generic cost clopidogrel 75mg brand plavix
buy allopurinol 300mg pill purchase zyloprim sale ezetimibe price
purchase methotrexate methotrexate 2.5mg cost reglan 20mg price
motilium usa domperidone canada cyclobenzaprine 15mg for sale
order baclofen generic baclofen 10mg cost toradol 10mg over the counter
colchicine price free slots online online gambling slots games
that roulette best casino blackjack games
purchase cialis for sale ampicillin 500mg without prescription order cipro 500mg generic
fluconazole sale pfizer viagra order sildenafil 100mg online cheap
buy generic cialis 40mg order cialis 40mg cheapest viagra
viagra 25mg for sale sildenafil medication buy cialis online
order generic ceftin 500mg order cefuroxime 500mg online cheap methocarbamol price
term papers writing service buy assignments ivermectin 3mg stromectol
sildenafil pharmacy cheap estradiol order lamictal generic
order deltasone for sale buy prednisone without prescription purchase amoxil sale
free casino order provigil 100mg generic modafinil 200mg uk
order furosemide without prescription hydroxychloroquine 200mg ca hydroxychloroquine without prescription
order prednisone 40mg pills oral prazosin mebendazole us
buy generic tadacip buy diclofenac 50mg order indocin 75mg without prescription
terbinafine price order terbinafine 250mg online cheap order amoxicillin generic
buy biaxin pill meclizine 25 mg pills meclizine 25mg us
purchase tiotropium bromide for sale hytrin cost cheap hytrin 5mg
cialis 5mg sale play poker online best online casinos real money
order tadalafil 20mg generic Cialis sales order cialis 20mg generic
fake online casino
huuuge casino slots vegas 777
free casino slots online
ivermectin purchase avlosulfon buy online dapsone 100mg sale
online blackjack gambling play poker online free casino world casino slots gambling
play online blackjack write college essays for money write my term paper
nifedipine 10mg without prescription adalat 10mg uk order allegra 180mg online
order doxycycline 200mg buy doxycycline 100mg for sale order cleocin 300mg online cheap
benicar 10mg oral order olmesartan 20mg pill divalproex 500mg drug
order asacol 800mg online buy astelin 10ml online cheap avapro price
order temovate temovate over the counter buy amiodarone 200mg pills
coreg 6.25mg sale order carvedilol sale elavil 10mg generic
buy amoxicillin 1000mg pills oral amoxicillin ivermectin cream 1
purchase dapoxetine online dapoxetine cost buy domperidone 10mg generic
purchase esomeprazole sale cheap lasix order furosemide 100mg without prescription
clomid oral atorvastatin 10mg tablet order generic prednisolone 5mg
buy isotretinoin for sale prednisone for sale cost ampicillin 250mg
order zofran sale buy amoxicillin 250mg online buy trimethoprim online cheap
provigil cost order metoprolol 50mg metoprolol us
cheap prednisolone sale order lasix 100mg for sale lasix cheap