If there are five numbers: 1, 2, 3, 4, 5, the algorithm is used to split and save several numbers into an array, the result is as follows: Array, 3, 4, 5 array, 3, 5 array, 2, 3, 4, 5 array, 2, 4 a total of 4 arrays, my goal is to put these 5 numbers in the four arrays each number appears 3 times, in this way, an array does not exist and all numbers can be retrieved from other arrays. Algorithms for splitting and saving several numbers
If there are five numbers: 1, 2, 3, 4, 5, to save to the array, the result is as follows:
Array, 5
Array 2: 1, 3, 5
Array
Array
There are 4 arrays in total. my goal is to display these 5 numbers three times in each of the four arrays, so that an array does not exist, all numbers can be retrieved from other arrays.
I don't need code. I just need to think about it. thank you.
------ Solution --------------------
Think about it, you are not raid5. you have a lot of redundancy in this solution.
To organize data like this, you can read data when any two groups of data are lost.
However, the organizational structure is slightly different from yours.
PHP code
$ Ar = array (, 5), array (, 5), array (, 5), array (, 4), array, 0),); unset ($ ar [3]); unset ($ ar [1]); for ($ I = 0; $ I <5; $ I ++) {$ m = 0; foreach ($ ar as $ v) $ m | = $ v [$ I]; echo $ m ;}
------ Solution --------------------
PHP code