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

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

WBOY
Release: 2016-06-13 13:13:21
Original
1103 people have browsed it

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


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

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

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