先了解一下数组,数组就是把一组数据按顺序放在一起,PHP的数组和其它的语言数组有一点点不同:第一,保存的数据是可以是任何类型的;第二,数组的索引可以是数字,也可以是字符串。
怎样创建在PHP中创建数组你可以使用如下的方法之一创建数组,实例代码如下:
- <?php
- $a="abcd";
- print($a[0]." ".$a[1]." ".$a[2]." ".$a[3]." ");
- ?>
- //结果:a b c d
方法二,代码如下:
- <?php
- $http=array("www","helpphp","cn");
- print($http[0].".".$http[1].".".$http[2]);
- ?>
PHP的数组,说白了,就是关联数据每一条数组都是以[索引,值]的形式保存的,其中索引默认是以0开始的数字,在未指定索引时,PHP会从0开始自动生成索引,当指定一个索引,PHP会从你指定索引最大正整数的下一个整数开始,如果你指定的是小数,PHP会取整数部分做为索引。
另外说说数组其它一些小东西:
array()可以声明一个空数组;
array[] = $value 在数组存在时,追加一个数据,在数组不存时,生成一个数组,并追加数据。
array[$index] = $value 在数组存在时,追加或修改一个数据,在数组不存时,生成一个数组,并追加数据。
看下面的代码:
- // 声明数组
- $test01 = array();
- // 追加数据
- $test01[] = "a"; // array(0 => "a");
- // 追加一个索引为"a",数据为"b"的数据
- $test01["a"] = "b"; // array(0 => "a", "a" => "b");
- // 修改索引为0的数据
- $test01[0] = "c"; // array(0 => "c", "a" => "b");
- // 另一种声明方法
- $test02 = array("a", "b", "c"); // array(0 => "a", 1 => "b", 2 => "c");
- // 虽然声明了一个字符串索引的数据,但默认索引还是从0开始
- $test03 = array("a" => "a", "b", "c"); // array("a" => "a", 0 => "b", 1 => "c");
- // 声明中最大的索引为2,虽然最近是索引是0,但默认索引还是从3开始
- $test04 = array(2 => "a", 0=>"b", "c"); // array(2 => "a", 0 => "b", 3 => "c");
- // 声明一个小数索引会取其整数部分;指定索引时,会修改之前声明的值
- $test05 = array("a", 2.7=>"b", 0=>"c"); // array(0 => "c", 2 => "b");
- // 虽然声明了负数索引,但默认索引还是从0开始
- $test06 = arra
- y(-2 =>"a", "b", "c"); // array(-2 => "a", 1 => "b", 2 => "c");
- // 多维数组的定义
- $test07 = array($test01, $test02, $test03);
然后介绍数组的一些填充函数,这些大多可以从手册上查到,所以只作简单的介绍。
range($n, $m); 指定值的范围,如range(2,4)生成数组 array(2,3,4)。
count($array); 取得数组的大小。
array_pad($array, $length, $value); 返回一个长度$length的数组,原不足数组补值为$value,长度足够返回原数组。
波比源码 » PHP入门教程之数组的定义和赋值
buy levofloxacin 500mg for sale levaquin 250mg cost
avodart over the counter order celecoxib 100mg without prescription buy zofran 8mg pills
order spironolactone generic buy valacyclovir generic buy fluconazole 100mg
buy acillin generic order generic ampicillin 250mg order erythromycin online
sildenafil 100mg cheap careprost generic methocarbamol uk
order suhagra online sildenafil pill order estradiol
buy lamictal 200mg buy lamictal 50mg generic purchase retin sale
purchase tadalis generic order voltaren 50mg pills order voltaren 100mg pill
purchase accutane generic buy zithromax 500mg generic zithromax 500mg pill
cheap cialis 40mg 100mg cialis desciption cheap sildenafil
anastrozole price Canadian healthcare viagra sales buy sildenafil 100mg without prescription
prednisone 5mg for sale deltasone 20mg for sale sildenafil overnight shipping usa
cialis generika rezeptfrei kaufen viagra 100mg kaufen sildenafil 200mg kaufen ohne rezept
purchase accutane sale zithromax 250mg us ivermectin pills
doxycycline 100mg without prescription doxycycline 100mg usa brand furosemide 100mg
purchase ramipril order avapro 300mg for sale order azelastine 10 ml without prescription
terazosin 5mg oral pioglitazone 15mg usa generic azulfidine 500mg
buy alendronate 70mg for sale purchase ibuprofen sale pepcid brand
isosorbide 20mg ca order generic imdur 20mg order micardis 20mg sale
oral molnunat 200 mg prevacid pill order lansoprazole 15mg online
cialis pills 40mg top rated generic viagra viagra 100mg cheap
order dapsone 100mg for sale order adalat generic aceon 4mg drug
order provera 5mg online order praziquantel 600mg periactin tablet
modafinil ca modafinil cheap ivermectin 15 mg
buy fluvoxamine online cheap brand luvox 100mg glucotrol 10mg us
isotretinoin us generic amoxicillin order prednisone 10mg online cheap
cialis pills 40mg order cialis online cheap order sildenafil 100mg generic
cialis 20mg us clomipramine 25mg for sale anafranil 50mg brand
chloroquine 250mg price buy generic aralen olumiant price
order generic norvasc 10mg viagra in usa buy cialis 40mg online
buy clozaril 100mg sale clozapine us dexamethasone uk
prilosec 10mg drug free slots games online casino game
buy lopressor pill brand lopressor levitra 20mg drug
thesis writing services slots real money blackjack for money
vardenafil buy online medrol 4 mg oral medrol 4mg oral
research paper website website to write essays sildenafil citrate 50mg
order tadalafil 5mg generic tadalafil order online viagra 100mg oral
tadalafil 5mg drug order sildenafil 100mg sale viagra cheap
cheap zyloprim 100mg buy allopurinol 300mg generic zetia 10mg cheap
methotrexate 10mg canada coumadin 2mg over the counter purchase metoclopramide pills
domperidone price buy flexeril for sale cyclobenzaprine 15mg sale
baclofen 10mg tablet order tizanidine 2mg pill toradol 10mg drug
buy imitrex 25mg without prescription imitrex 50mg pill avodart 0.5mg cost
cheap cialis generic cipro usa order cipro pill
cephalexin tablet cephalexin 250mg cheap erythromycin over the counter
viagra 50mg pills viagra pharmacy buy cialis 10mg online cheap
order generic cefuroxime 500mg methocarbamol online order robaxin over the counter
play poker online for real money tadalafil 20mg sale brand cialis 5mg
purchase desyrel without prescription buy sildenafil 50mg online sildenafil pill
purchase sildalis online buy estradiol online cheap lamictal for sale online
order viagra 100mg without prescription tadalafil oral price of cialis
buy zithromax sale purchase azithromycin for sale neurontin 800mg for sale
play slots for real money united states buy generic cialis 20mg tadalafil generic name
buy lasix generic buy doxycycline 200mg sale order plaquenil 200mg
buy prednisone 5mg generic deltasone 20mg us order mebendazole 100mg pill
order sildenafil 50mg sale order fildena pill rhinocort allergy nasal spray
tretinoin cream generic order tretinoin gel buy avana generic
buy tadacip 20mg for sale buy diclofenac generic order indomethacin online cheap
biaxin 250mg generic meclizine ca buy antivert 25mg for sale
spiriva 9 mcg oral spiriva drug terazosin 5mg cheap
order pioglitazone 30mg online buy sildenafil 100mg sale cost viagra 50mg
montelukast pill buy singulair 10mg generic order viagra 100mg
free slot games for fun online pharmacy canadian write research papers
buy nifedipine 10mg without prescription order perindopril 4mg sale fexofenadine 180mg over the counter
order an essay online sulfasalazine order online cost azulfidine 500mg
olmesartan 20mg generic olmesartan over the counter buy generic depakote 250mg
doxycycline 200mg pills purchase ventolin inhalator for sale clindamycin sale
buy mesalamine 400mg for sale irbesartan sale buy avapro generic
purchase digoxin generic digoxin 250mg over the counter order molnupiravir
clobetasol cost order buspirone for sale order amiodarone without prescription
amoxicillin online buy amoxil sale ivermectin 5ml
purchase fosamax for sale buy alendronate 35mg motrin 400mg oral
buy generic priligy 30mg buy priligy 90mg pills buy motilium sale
order generic famotidine 40mg buy prograf 1mg online cheap order remeron 15mg pill
doxycycline price doxycycline 100mg price buy methylprednisolone 4 mg online
Thank you for content. Area rugs and online home decor store. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
generic tricor 200mg order fenofibrate online generic viagra
esomeprazole over the counter buy esomeprazole 20mg online cheap lasix 40mg tablet
buy cialis 40mg for sale Canadian healthcare tadalafil sildenafil 50mg for sale
minocin 50mg capsules neurontin 800mg uk hytrin 1mg brand
I really love to read such an excellent article. Helpful article. Hello Administ . Onwin , Onwin Giriş , Onwin Güncel Giriş , Onwin Yeni Adres , onwin
order modafinil 200mg pill buy stromectol 3mg for sale purchase promethazine generic
brand prednisone 5mg buy amoxil 500mg pills buy generic amoxicillin 250mg
buy ed pills generic pills for erection finasteride drug
stromectol ireland cheap stromectol 12mg cheap prednisone 20mg
buy ondansetron without prescription buy sulfamethoxazole without prescription bactrim 480mg us
accutane online buy amoxicillin 500mg for sale purchase zithromax pills
ventolin 2mg canada albuterol us cheap augmentin 1000mg
buy generic modafinil metoprolol online buy generic lopressor 50mg
prednisolone uk prednisolone 20mg uk purchase lasix generic