Home  >  Article  >  Backend Development  >  php对象输出有顺序吗?解决方法

php对象输出有顺序吗?解决方法

WBOY
WBOYOriginal
2016-06-13 13:13:211034browse

php对象输出有顺序吗?
php对象输出有顺序吗?好像以前记得说是随机输出的,js对象随机输出?


------解决方案--------------------
不知道你在说什么!
asort 前后,数组元素的排列次序发生了变化。难道都看不见?
------解决方案--------------------
asort($fruits);
print_r($fruits); //可以看到数组的顺序改变了。

foreach 不会改变顺序,只是逐次遍历。

Statement:
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