Ask for newping

I’am new to programming. Please help.

I need to use sensor value form newping to other function. How can I do that.

Thank for every advice. ^^

/////////////////////code////////////
#include <NewPing.h>

#define SONAR_NUM 3      
#define MAX_DISTANCE 200 

NewPing sonar[SONAR_NUM] = {  
 NewPing(2, 3, MAX_DISTANCE), 
 NewPing(4, 5, MAX_DISTANCE), 
 NewPing(6, 7, MAX_DISTANCE)
};

void setup() {
 Serial.begin(115200); 
}

void loop() { 
 for (uint8_t i = 0; i < SONAR_NUM; i++) { 
   delay(50); 
   Serial.print(i);
   Serial.print("=");
   Serial.print(sonar[i].ping_cm());
   Serial.print("cm ");
   
 }
 Serial.println();

 // I need to use sonar0, sonar1, sonar2 here.
}

void myFunction() {

 //And I need sonar0, sonar1, sonar2 value here.
}

Hopefully, you can see why we ask you to use code tags when posting code.

Store the values returned in an array.

AWOL: Hopefully, you can see why we ask you to use code tags when posting code.

Store the values returned in an array.

Where to see example.

The IDE is jam-packed with examples

The reference has an example of using an array of sensors and storing the returned ranges in an array.