2012-10-06 149 views
-2

我有PHP數組PHP數組隨機

Array(
[0] => Array 
    (
     [boxId] => 917 
     [contentId] => 72 
     [sectionType] => hp_spl_contestants 
     [contentTypeId] => 83 
     [categoryId] => 0 
     [countryId] => 5 
     [data] => {"title":"Contestant No.1","button_txt":"Latest From","image":"2d4f8f52d49d1ab9930bc40157013a31.jpg","author":"Meenakshi Negi","url":"","date":"2012-10-04 18:16:30","badget":0,"badget_date":""} 
     [insertDate] => 2012-10-05 21:05:57 
     [sortorder] => 1 
     [sitename] => bb6 
    ) 

[1] => Array 
    (
     [boxId] => 918 
     [contentId] => 63 
     [sectionType] => hp_spl_contestants 
     [contentTypeId] => 83 
     [categoryId] => 0 
     [countryId] => 5 
     [data] => {"title":"Contestant No.2","button_txt":"Latest From","image":"37154a5322838f61fb60cc24c8b5fe04.jpg","author":"Meenakshi Negi","url":"","date":"2012-10-04 18:09:06","badget":0,"badget_date":""} 
     [insertDate] => 2012-10-05 21:06:16 
     [sortorder] => 2 
     [sitename] => bb6 
    ) 

[2] => Array 
    (
     [boxId] => 919 
     [contentId] => 64 
     [sectionType] => hp_spl_contestants 
     [contentTypeId] => 83 
     [categoryId] => 0 
     [countryId] => 5 
     [data] => {"title":"Contestant No.3","button_txt":"Latest From","image":"f90ba1195b1dd5a57308b46e1b248d49.jpg","author":"Meenakshi Negi","url":"","date":"2012-10-04 18:09:06","badget":0,"badget_date":""} 
     [insertDate] => 2012-10-05 21:06:36 
     [sortorder] => 3 
     [sitename] => bb6 
    ) 

[3] => Array 
    (
     [boxId] => 920 
     [contentId] => 65 
     [sectionType] => hp_spl_contestants 
     [contentTypeId] => 83 
     [categoryId] => 0 
     [countryId] => 5 
     [data] => {"title":"Contestant No.4","button_txt":"Latest From","image":"d439ab109de8202914ea7439c1f7650b.jpg","author":"Meenakshi Negi","url":"","date":"2012-10-04 18:09:06","badget":0,"badget_date":""} 
     [insertDate] => 2012-10-05 21:06:55 
     [sortorder] => 4 
     [sitename] => bb6 
    ) 

我們可以隨機化這個數組其價值

+0

值的arent隨機的。但他們可能會被洗牌。請更具體一些。 – Repox

回答

2

你可以使用shuffle功能。

shuffle($cdata); 
+0

我已經試過這個但不起作用 – user493619

+0

什麼不起作用? – xdazz

+0

數組值無法獲得suff – user493619