Declare for loop as an array of variables
You don't even have to add any lines, just modify a couple!

unsigned long ultrasoundValue [2]; //creates an array of unsigned longs of size 2


...and inside your for loop:

ultrasoundValue[i] = ping(i);


It appears you are acquiring 2 separate ultrasound values. If you'd like to store multiple sets of these 2 values, you could use a two-dimensional array:

unsigned long ultrasoundValue [10][2]; //an array of 10 pairs of long unsigned values


...and you could modify your for loop to have a pair of nested for loops:

 for (int i = 0; i &lt; 10; i++)
 {
   for (int j = 0; j &lt; 2; j++)
   {
      ultrasoundValue[i][j] = ping(j);
      //do whatever else
   }
 }