php: éè¿keyè·åå¤ç»´æ°ç»ä¸çå¼_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: éè¿keyè·åå¤ç»´æ°ç»ä¸çå¼
2017-06-12 20:19
éè¿å¤ç»´æ°ç»ä¸çkeyè·åvalue
å设æ以ä¸å¤ç»´æ°ç»
$array = [
‘zero’=>[
‘e’=>’ss’,
‘f’=>’dd’,
],
‘e’=>’111’,
‘second’=>’222’,
‘third’=>’333’
];
å¦æç¥éäºå¤ç»´æ°ç»ä¸çæ个keyå¼ï¼ æ们å¯ä»¥ç¨éå½æ¥è·åè¿ä¸ªkey对åºçvalueï¼ä½é¤äºéå½ï¼æ们è¿å¯ä»¥ç¨array_walk_recursiveå½æ°æ¥å®æè¿ä¸ªæä½
/** obtain the value by key
*
*
*/
function recur($key, $array){
$data = [];
array_walk_recursive($array, function ($v, $k) use ($key, &$data) {
if ($k == $key) {
array_push($data, $v);
}
});
return $data;
}
$data = recur(‘e’, $array);
print_r($data);
array_walk_recursiveå½æ°æ两个åæ°ï¼ 第ä¸ä¸ªåæ°ä½¿æ们è¦å¤ççæ°ç»ï¼ç¬¬äºä¸ªåæ°æ¯ä¸ä¸ªåè°å½æ°ï¼è¿æ¯ä¸ä¸ªæ们èªå®ä¹çå½æ°ãå¨è¿ä¸ªå½æ°ä¸ï¼æä»¬è®¾å® å¦æ$kçäºæ们ç»å®çkeyé®å¼ï¼å°±å°è¿ä¸ªkeyæ对åºçå¼valueå å ¥å°$dataæ°ç»ä¸ã
å ¶ä»å½æ°
类似çå½æ°è¿æarray_walkï¼ä½è¿ä¸ªå½æ°åªè½åºç¨ä¸ç»´æ°ç»ï¼è¦æ¯ç¨å¤ç»´æ°ç»ï¼ç¨array_walk_recursiveæ´å¥½
ç¸å
³æç´¢ï¼
jspä¸ç注é
c++ä¸ç~
人工æºè½ä¸çå¾è¡¨æ¨ç
å¤ç»´å¾è¡¨
linq æ°ç»
ç¸å ³æç«
2016-08-29 10:33 php å¤ç»´æ°ç»ç¸åkeyçvalueå¼ç´¯å å½æ°
2015-01-23 21:02 phpå¤ç»´æ°ç»ævalueå¼èµå¼å°key
2014-10-29 20:44 phpå¦ä½å¤æå¤ç»´æ°ç»ä¸æ¯å¦å
å«ç©ºå¼
2015-08-15 04:31 phpä¸å¤ç»´æ°ç»å¾ªç¯éåé®é¢ã
2017-03-26 03:30 6.éè¿æ°ç»éçå¼æ¾æ°ç»çkey
æ´å¤ç¸å ³æç« >>
ææ°æç«
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 æ件ä¸ä¼
æ´å¤ææ°æç« >>
çé¨æç´¢
delphi æ°ç»
jspè·åipå°å
vb.net æ°ç»
vcç»å¯¹å¼
xmlå±æ§å¼
delphi 空å¼
delphi æ°ç»æé
c++æ°ç»
sqlserver表å¼å½æ°
php jsp
php webservice
php å¾è¡¨
php xml
delphi for php
delphi php
京icpå¤14022385å·-2
©2014 itnose软件ç¼ç¨æç¨ | èç³»æ们ï¼emailï¼twobrushes@126.com qq:35155868