This notebook solves (Subscript[u, t])=(Subscript[u, xx])  with t>0, xϵ(0,1) and u(0,x)=phi(x) and u(t,0)=0=u(t,1).
Note the importance of running with the proper ratio α=Δ(t/(((Δx))^2))when using this Explicit (Forward-Difference) method.

n = 10;
dx = 1/n;
m = 200;
dt = 1/m // N;
alpha = dt/(dx^2);
Print["alpha = ", alpha];

  
  
 (* note that φ threads over the vector x so that phi[x] is an n+1-vector *)
phi[x_] := Sin[Pi x];
x = Table[i/n, {i, 0, n}] // N;
v = Table[0, {j, 0, m}, {i, 0, n}]; 
v[[1]] = phi[x]; 

  
u = 
            Table[{i/n, v[[1, i + 1]]}, {i, 0, n}];
ListPlot[u, PlotJoined -> True,  
            PlotRange -> {0, 1}];

  
For[j = 2, 
            j ≤ 
              m + 1, j++, 

 (* 
              loop from (Subscript[x, 1]) to (Subscript[x, n - 1]),  
              since (Subscript[x, 0]) = 0 = (Subscript[x, 1]),  i . e . ,  
              columns 2 through n of the 2 - 
                dim temp array *) 
For[i = 2, 
              i ≤ 
                n, i++, 

 (* 
                MAIN LINE OF CODE,  
                Explicit Finite Difference Equation *) 
v[[j, i]]  =  
                  v[[j - 1, i]]  + 
                    alpha*(v[[j - 1, i - 1]] - 2*v[[j - 1, i]] + 
                          v[[j - 1, 
                              i + 1]]);

];   (* 
              end space loop *) 

 (* 
              Plot every skip1 time slices *) 
skip1  =  20; 
 
            If[Mod[j, skip1] == 0, 
u = 
                Table[{i/n, v[[j, i + 1]]}, {i, 0, 
                    n}]; 
ListPlot[u, 
                PlotJoined -> True, 
                PlotRange -> {0, 1}], 
 
              Null  (* 
                else do nothing *) 
];

];   

  
skip2  =  40;
ListPlot3D[Take[v, skip2]]