Home  >  Article  >  Backend Development  >  Php 读取json_decode数据的问题

Php 读取json_decode数据的问题

WBOY
WBOYOriginal
2016-06-23 13:59:351014browse

有6条json数据数据如何让他随机 显示出来?
我用 
foreach ($content as $key) {
   echo $key->bucket_name; 
  }
他是按顺序显示出来的 要怎么才能让他随机显示出来 并且不重复 
求大神 解答 希望能给一下思路 但是有代码就跟好了 谢谢 


回复讨论(解决方案)

随机显示:shuffle
不重复:array_unique.

随机显示:shuffle
不重复:array_unique.

请问这个要放在那里

$content = shuffle($content); //打乱$contentforeach ($content as $key) {   echo $key->bucket_name; }

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