Home > Backend Development > PHP Tutorial > 分享一行代码

分享一行代码

WBOY
Release: 2016-06-23 14:05:39
Original
808 people have browsed it

$arr = array(2=>'PHP','2'=>'mysql','2.5'=>'linux',2.5=>'apache');  
var_dump($arr); 
先仔细思考下,然后再运行下结果。


回复讨论(解决方案)

'2.5'不变
'2'转为2
2.5取整为2
后面赋值的覆盖前面的

结果略

思考同上,结果如下:
array(2) { [2]=> string(6) "apache" ["2.5"]=> string(5) "linux" }

长见识啦!长见识啦!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template