phpæ°ç»åçéååçæç§_php_web-itnose
é¦é¡µ
asp
php
javascript
iis
apache
html/css
coldfusion
ajax
vbscript
cgi
xml/xsl
è·¨æµè§å¨å¼å
ruby/rails
ç¨åºå
html5
jquery
seo
jboss
json
angularjs
markdown
nginx
thinkphp
yii
pageadmin
extjs
wampserver
kendo ui
coffeescript
gulp
ecmascript
bootstrap
itnoseé¦é¡µ > web > php >
phpæ°ç»åçéååçæç§
2017-02-24 17:07
phpä¸çä¸çæ°ç»è·jséé¢æ°ç»æ¯ä¸å¤§ä¸æ ·çãphpä¸æ°ç»çä¸æ å¯ä»¥æ´æ°ä¹å¯ä»¥æ¯å符串ï¼èä¸æ°ç»ä¸å ç´ ç顺åºä¸æ¯ç±ä¸æ å³å®çï¼èæ¯ç±æ·»å å ç´ ç顺åºãæ°ç»åºç¡
$arr1 = array(å ç´ 1ï¼å ç´ 2ï¼ããããã );array(1, 5, 1.1, âabcâ, true, false);//å¯ä»¥åå¨ä»»ä½æ°æ®ï¼æ¤æ¶ä¸ºâé»è®¤ä¸æ âï¼array(2=>1, 5=>5, 3=>1.1, 7=>âabcâ, 0=>true);//ä¸æ å¯ä»¥ä»»æ设å®ï¼æ é顺åºï¼æ éè¿ç»ï¼array(2=>1, 5, 1=>1.1, âabcâ, 0=>true)//å¯ä»¥å ä¸æ ï¼ä¹å¯ä»¥ä¸å ï¼é»è®¤ä¸æ ï¼,ä¸æ åå«æ¯ï¼2,3,1,4,0//é»è®¤ä¸æ è§åï¼åé¢å·²ç»ç¨è¿çæ大æ°åä¸æ +1array(2=>1, âddâ=>5, 1=>1.1, âabcâ, 0=>true)//æ··åä¸æ ï¼åæ ·éµå¾ªé»è®¤ä¸æ è§åarray(-2=>1, âddâ=>5, 1.1, âabcâ, true);//è´æ°ä¸æ ä¸ç®å¨æ´æ°ä¸æ ä¸ï¼èåªå½ä½å符ä¸æ //åæå3项çä¸æ æ¯ï¼0, 1, 2array(2.7=>1, âddâ=>5, 1=>1.1, âabcâ, 0=>true)ï¼//æµ®ç¹æ°ä¸æ 为èªå¨è½¬æ¢ä¸ºæ´æ°ï¼ä¸ç´æ¥æ¹æå°æ°array(â2.7â =>1, âddâ=>5, â11â=>1.1, âabcâ, true)//纯æ°åå符串ä¸æ ï¼å½ä½æ°åçå¾ ï¼//åæ¤æ¶ä¸æ 为ï¼2, âddâ, 11, 12, 13array(2=>1, âddâ=>5, true=>1.1, âabcâ, false=>true)//å¸å°å¼å½ä¸æ ï¼åtrue为1ï¼false为0ï¼array(2=>1, âddâ=>5, 2=>1.1, âabcâ, true)//å¦æä¸æ è·åé¢çéå¤ï¼åå纯è¦çåé¢ååä¸æ çå¼//æ¤æ¶ç¸å½äºä¸ºï¼array(2=>1.1, âddâ=>5, âabcâ, true)å ¶ä»å½¢å¼ï¼$arr1[] = 1;$arr1[] = 5;$arr1[] = 1.1;//ç´æ¥å¨åéåé¢ä½¿ç¨[]ï¼å°±æ为æ°ç»ï¼å¹¶ä¾æ¬¡èµå¼ããããã$arr2[âaaâ] = 1;$arr2[âbbbccâ] = 5;$arrr2[5] = 1.1;ããããããããè¿ç§å½¢å¼åçä¸æ ï¼å ¶å®è·ä½¿ç¨arrayè¯æ³ç»æå ä¹ä¸æ ·ãåå¼ï¼éè¿ä¸æ ãèµå¼ï¼åå®ä¹ï¼ï¼æ°ç»éåï¼
éååºæ¬è¯æ³ï¼foreach( $arr as [ $key => ] $value ) //$keyå¯ä»¥ç§°ä¸ºé®åéï¼$valueå¯ä»¥ç§°ä¸ºå¼åéã{//è¿éå°±å¯ä»¥å¯¹$key å $value è¿è¡ææå¯è½çæä½ââå 为ä»ä»¬å°±æ¯ä¸ä¸ªåé//$key 代表æ¯æ¬¡åå¾å ç´ çä¸æ ï¼å¯è½æ¯æ°åï¼ä¹å¯ä»¥è½æ¯å符串//$value 代表æ¯æ¬¡åå¾å ç´ çå¼ï¼å¯è½æ¯åç§ç±»åã//æ¤å¾ªç¯ç»æä¼ä»æ°ç»ç第ä¸é¡¹ä¸ç´éå循ç¯å°æåä¸é¡¹ï¼ç¶åç»æã}æ°ç»æéåéååçï¼æ¯ä¸ªæ°ç»å é¨é½æä¸ä¸ªâæé âï¼è¯¥æéæå®äºå½åæ°ç»åå¼åå°çæ¯æ个å ç´ ãå ¶å®æè°çéåå°±æ¯æéä¸æ¬¡ç§»å¨ï¼ç¶ååå¼æä½ãä¸é¢æä¸ä¸ªè·æéæå ³çæ°ç»å½æ°ï¼1ã$v1=current($arr) //åå°å½åæ°ç»æéæåçå ç´ çå¼ï¼æ²¡æåè¿åfalse;2ã$v1 = key($arr) //åå°å½åæ°ç»æéæåçå ç´ çä¸æ ï¼æ²¡æåè¿åfalseï¼3ã$v1 = prev($arr) //å°æé移å¨å°âä¸ä¸ä¸ªå ç´ âï¼å¹¶ä¸åå°å®çå¼ï¼4ã$v1 = next($arr) //å°æé移å¨å°âä¸ä¸ä¸ªå ç´ âï¼å¹¶ä¸åå°å®çå¼ï¼5ã$v1 = reset($arr) //å°æé移å¨å°â第ä¸ä¸ªå ç´ âï¼å¹¶ä¸åå°å®çå¼ï¼6ã$v1 = end($arr) //å°æé移å¨å°âæåä¸ä¸ªå ç´ âï¼å¹¶ä¸åå°å®çå¼7ã$v1 = each($arr) //åå¾æéå½åæåçå ç´ çä¸æ åå¼ï¼å¹¶ä¸å°æé移å°ä¸ä¸ä¸ªå ç´ ï¼æ²¡æåè¿åfalseãfor+next+resetéåæ°ç»phpæ°ç»åçéååçæç§
while+each+listéå说å°è¿ä¸ªéåï¼é¦å æ们è¦äºè§£ä¸ä¸eachålistçåè½each($arr);è¿åæ°ç»æéå½åæåçå ç´ çé®åå¼ï¼å¹¶ä¸æ¯å份ï¼å¹¶ä¸ç§»å¨æéå°ä¸ä¸ä½ï¼å¦æ没æï¼åè¿åfalse;æè°çå份æ¯ä»ä¹ææ?æ们æµè¯ä¸ä¸å³å¯ï¼phpæ°ç»åçéååçæç§
ç»æ:phpæ°ç»åçéååçæç§
åå°äºç¬¬ä¸ä¸ªå ç´ çä¸æ åå¼ï¼å两份ï¼èä¸æ¤æ¶æ°ç»æéä¹æåäºç¬¬äºå ç´ ãlist($v1,$v2,$v3â¦â¦)=$arr listçåè½å°±å¾å¥æªäºphpæ°ç»åçéååçæç§
phpæ°ç»åçéååçæç§
ä¾æ¬¡åå¾æ°ç»ä¸å¯¹åºç´¢å¼çå¼ï¼ä¸è¿åªè½åå°æ°ç»ä¸ç´¢å¼ä¸º0,1,2â¦â¦è¿äºå¯¹åºçå¼ãå¦æç´¢å¼æéå¤çï¼ååé¢å¼è¦çåé¢å¼ãæ¥ä¸æ¥å°±å¯ä»¥éè¿è¿äºè¿è¡æ°ç»éåäºï¼phpæ°ç»åçéååçæç§
phpæ°ç»åçéååçæç§
foreachéå:è¿ä¸ªæ¯æ们常è§çéåæ¹å¼ï¼ä¸è¿è¿ä¸ªæ¹å¼ä¹æä¸ä¸ªå¾ç¹å«çå°æ¹ï¼å½æ们éåè¿ç¨ä¸å¯¹æ°ç»è¿è¡æ¹åï¼åä¼æ·è´ä¸ä¸ªåæ°ç»ç»§ç»éåãå¯è½è¿éä¸å¤ªå¥½ç解ï¼ä¸è¿çä¸ä¸ä¾åå°±æç½äºãphpæ°ç»åçéååçæç§
phpæ°ç»åçéååçæç§
å¯è§ï¼æ°ç»å ¶å®å·²ç»æ¹åäºï¼ä½æ¯foreachéååºæ¥ç并没æå¢å çåªä¸é¡¹ãæ¤æ¶ï¼æ们ä¹å¯ä»¥è¾åºä¸ä¸å½åæéä½ç½®ï¼phpæ°ç»åçéååçæç§
phpæ°ç»åçéååçæç§
æ°ç»æéåçå¨äºä½ç½®3ä¸ãç±æ¤å¯ä»¥æ¨æï¼æ¬æ¥æ¯å¨åæ°ç»ä¸è¿è¡éåçï¼ç»ææ°ç»åçæ¹åï¼ç¶åæ·è´äºä¸ä¸ªåæ°ç»ï¼å¨æ·è´çæ°ç»ä¸å®æåé¢çéåã
æ¬æç±ç²çªcpaèçæ´çç¼è¾ï¼
ç¸å
³æç´¢ï¼
hibernate åç
springåç
webserviceåç
webservice åç
linq åç
ç¸å ³æç«
2014-02-08 11:59 phpåçï¼phpåºå±å·¥ä½åç
2017-03-21 17:11 php foreachåç详解
2017-03-09 14:42 phpåºå±å·¥ä½åç
2016-12-06 20:58 phpå页ææ¯åç
2015-07-26 18:11 phpä¸ä¼ åçä¸å®ä¾
æ´å¤ç¸å ³æç« >>
ææ°æç«
2017-06-20 01:35 èé们ï¼æ没æå¯è½è®©phpæ件åæ¶åªè½ä¸ä¸ªäººè®¿é®
2017-06-20 01:35 æä¹ç¦æ¢å¾çç´æ¥éè¿url访é®
2017-06-20 01:35 æ±æ!å¯å¨wampåªè½ç¨æ¬æºè®¿é®,åå±åç½çå
¶å®è®¾å¤è®¿é®ä¸å°!æäºå¤§å天t-t
2017-06-19 15:35 nginxä¸çthinkphpé®é¢
2017-06-19 15:35 php form æ件ä¸ä¼
æ´å¤ææ°æç« >>
çé¨æç´¢
linqåç
javaåºç¡åç
ejbå·¥ä½åç
hibernateå·¥ä½åç
springå·¥ä½åç
springæ¡æ¶åç
spring aopå®ç°åç
webserviceå·¥ä½åç
æ°æ®åºåç
æ°æ®åºç³»ç»åç
linq éå
spring æç§
springæç§
.netå®å
¨æç§
linq æ°ç»
京icpå¤14022385å·-2
©2014 itnose软件ç¼ç¨æç¨ | èç³»æ们ï¼emailï¼twobrushes@126.com qq:35155868