==
→ ===
<?php
$arr = [
'hello' => 'world',
'world' => 'hello',
'what' => 'the hell',
'0' => 'zero in string key',
0 => 'zero in int key',
1 => 'one in int key',
];
var_dump($arr);
foreach($arr as $k => $v){
echo '-------------------'.PHP_EOL;
echo ($k=='hello'? '√': 'X').' | '.$k .'==hello'.PHP_EOL;
echo ($k=='world'? '√': 'X').' | '.$k .'==world'.PHP_EOL;
echo ($k=='what'? '√': 'X').' | '.$k .'==what'.PHP_EOL;
echo ($k=='0'? '√': 'X').' | '.$k .'==0'.PHP_EOL;
echo ($k=='1'? '√': 'X').' | '.$k .'==1'.PHP_EOL;
}
输出:
array(5) {
["hello"]=>
string(5) "world"
["world"]=>
string(5) "hello"
["what"]=>
string(8) "the hell"
[0]=>
string(15) "zero in int key"
[1]=>
string(14) "one in int key"
}
-------------------
√ | hello==hello
X | hello==world
X | hello==what
X | hello==0
X | hello==1
-------------------
X | world==hello
√ | world==world
X | world==what
X | world==0
X | world==1
-------------------
X | what==hello
X | what==world
√ | what==what
X | what==0
X | what==1
-------------------
√ | 0==hello
√ | 0==world
√ | 0==what
√ | 0==0
X | 0==1
-------------------
X | 1==hello
X | 1==world
X | 1==what
X | 1==0
√ | 1==1
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.