In reply to krishna_:
Suggestion: use a queue array instead of a dynamic array.
task automatic masking(bit [15:0] strobe);
for(i = 0; i<16; i=i+1) begin
if(strobe[i]==1) begin
temp.push_front(wdata[8*i+:8]); //use push_front if you want to least significant
end //byte of wdata to be stored at higest index of
end //temp or else if least significant byte to be
endtask //stored at lower index of temp use push_back