I have this example of an array of objects and I need to randomize it each time I do a foreach loop.
Looks like shuffle works only on arrays.
One thing is that I cant convert this into an array, because then it will become a STD object which I can't use, because of the way my mapper works.
array(48) {
[0] => object(Friends_Model_Friends)#142 (4) {
["_id":protected] => NULL
["_tal":protected] => object(stdClass)#194 (3) {
["thumb"] => object(stdClass)#196 (6) {
["id"] => string(8) "10884697"
["type"] => string(1) "2"
["gallery"] => string(1) "1"
}
}
["_friend":protected] => string(7) "3492149"
["_dependent_table":protected] => NULL
}
[1] => object(Friends_Model_Friends)#195 (4) {
["_id":protected] => NULL
["_tal":protected] => object(stdClass)#143 (3) {
["thumb"] => object(stdClass)#202 (6) {
["id"] => string(8) "11160632"
["type"] => string(1) "2"
["gallery"] => string(1) "1"
}
}
["_friend":protected] => string(7) "3301541"
["_dependent_table":protected] => NULL
}
....
Any ideas on shuffling this?
edit: Zend_Debug::dump(shuffle($object)); returns bool(true)
shuffleonly works with arrays and you can't convert it [the array] into an array, because it will become an object? Sorry, but that makes completely no sense to me...shuffle()and it didn't shuffle the array?shuffle()call? In what way does it not work? Can you show the code you used to call it?Zend_Debug::dump(shuffle($object));i getbool(true)shuffle()shuffles the array, but returns a boolean.