This will create an array of 16 (4x4) zeros. for (%i = 1; %i <=4; %i++) for (%j = 0; %j <=4; %j++) { $var[%i+%j]=0; echo(" ",$var[%i+%j]); }