I'm using php, and it is pretty much the same as this C++ question: link I'm wondering if there is an easier way to do it than making a function.
Example code
array[9] = 1;
array[5] = 1;
array[14] = 1;
array[8] = 2;
array[15] = 2;
array[23] = 2;
array[12] = 2;
Edit : by easier I mean less tedious and less lines