Sowhythiscouldbevaluableisifyou'regoingtobedoingsomething, let's sayyou'rehaving a partyoryou'rehavinganeventandmultiplepeoplewillbecomingtoyoureventandyouwanttobe a littlelistoutwhothosepeopleareinalphabeticalorder.
Now, ifyouwereusingbasicvariablesinordertoaddallthosenamesandindividualvariablesandthen B of a sortthatandprintedout, itwouldbe a complicatedprocess.
Putinallofthesedifferentnames, thenwhatyoucoulddoisyoucando a sortonthatarrayeitheralphabeticallyorreversealphabetically, andthenyoucanprintouttheresultsofthatsort.
SoItmakeslife a loteasierwhenyou'regoingtobedoingthingslikeifyouhave a largelistortheotherthingthatyoucoulddoisifyou'regoingtobecollecting a numberofbitsofinformationabout a certainsum, let's say a certainperson.
Solet's sayyouwanttouseinformationabout a personbecauseyou'reusingsomekindofcontactrelationshipmanagementsoftware.
Sothetworeasonsthatyougenerallyuse a raiseseitheryou'recreating a list.
Soallthisinformationgoesinto a listsothatyoucanyoucanorderit, youcansortit, orifyou'retryingtocollect a lotofinformation, a lotofdifferentpieceofinformation, basicallyessentiallyaboutonevariable, let's saylike a userorsomethinglikethat.
Whereasif I showyou a differentwayofcreatinganarray, it'llworkandpeeHBseven.
Butitwon't work.
AndPHPfour.
Sothatissomethingtorealizeifyou'reIfyou're a coderthatknowswhat's goingon.
You'rewonderingwhy I'm showingthis.
I'm justshowingthisforeasesopeoplecangetusedtoitandtorealizeifyouknowyou'reworkingon a platformthathasPHPseven, thereis a differentwaytocreate a raisethatthatlooks a lotbetterandis a littlebiteasiertodio.
Butthiswillworkregardless.
So I created a scriptrighthere.
Thealwayscalledis a raydotPHPandofcourse, create a script.
Westartwith a PHPtag.
Thenfromhere, whatwe'regoingtodoiswe'regoingtocreatethearray, sothislooks a lotlikecreatingandsettingthevalueforvariable.
Sothisisgonnabelikefor a listofnamesagainfor a partyorforeventorsomethinglikethat.
We'regoingtosay, doistheyweregoingtosayitequalsAndthenweusedthearrayfunctionsoftherayfunctionisgoingtoaddallofthesenamesintothearray s O.
Wedoparenthesesandthendosinglequotationmark.
Sowe'regonnabedoingisthevaluesarebetweensinglequotationmarksandthenyouseparateby a commaIt's a singlequotationMarkBobCloseSinglequotationmarkcommasinglequotationmarksSuesinglequotationmarkandwith a comma.
Sojustremember, basicallyyouendwith a commaallthewaytothelastoneAndthenyouclosetheparenthesesAnd, ofcourse, youfinishwiththesemicolonandthisisallyouhavetodoinordertocreateanarray.