How to use a ping sensor to control a servo?

Well the best way is to just learn how each device works separately. One is an input device, the ping sensor. Learn how to wire it up. Try out some of the example sketches and libraries that use that device. Then learn to use the output device, the servo. There are plenty of example sketches. Once you have a good understanding of each device on it's own and how they are used in a sketch, you should have little trouble combining them into one sketch that performs as you wish.

Lefty