すべてのキーの値として stdClasses を含む配列をランダム化したいのですが、stdclasses の順序はオリジナルでなければなりません。
たとえば、元の配列は次のようになります。
Array(
[0]=>stdClass(/*lots of keys with value that must stay here and stay in order
for example [id]=1 [name]=One*/)
[1]=>stdClass(/*lots of keys with value that must stay here and stay in order
for example [id]=2 [name]=Two*/)
[2]=>stdClass(/*lots of keys with value that must stay here and stay in order
for example [id]=3 [name]=Three*/)
[3]=>stdClass(/*lots of keys with value that must stay here and stay in order
for example [id]=4 [name]=Four*/)
)
これが私が達成したいことです:
Array(
[3]=>stdClass(/*lots of keys with value that must stay here and stay in order
for example [id]=4 [name]=Four*/)
[0]=>stdClass(/*lots of keys with value that must stay here and stay in order
for example [id]=1 [name]=One*/)
[1]=>stdClass(/*lots of keys with value that must stay here and stay in order
for example [id]=2 [name]=Two*/)
[2]=>stdClass(/*lots of keys with value that must stay here and stay in order
for example [id]=3 [name]=Three*/)
)
私はこの関数PHP Random Shuffle Array Maintaining Key => Value を試しましたが、これは stdClasses もシャッフルし、それは良くありません。たとえば、ゼロ キーの class->id は 3 番目のキーにシャッフルされます
そして、これを正しい方法でランダム化する方法がわかりません。