This library provides some functions to make life easier when using PubSubClient for Arduino
The library comes with a number of example sketches. See File > Examples > PubSubClientTools within the Arduino application.
PubSubClient