H
H
hollanditkzn2018-03-20 17:30:25
Yii
hollanditkzn, 2018-03-20 17:30:25

How to display the value of an array in random order from json_decode?

I have a model where, when displayed on a page, it decodes a string into an array

public function afterFind()
    {
        $this->answear = json_decode($this->answear, true);
    }

But in the record I can’t get it to shuffle it
An example of how I shuffle an array in a view
shuffle($model[0]->answear);
var_dump($model[0]->answear);

This is a good example, only the whole array does not change the order of the value and remains the same. The question is how to move the array in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-03-20
@hollanditkzn

But in the record it does not work for me to mix it

why? How do you do what's in it? Output it via var_dump, perhaps there is still nesting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question