SSH2 in PHP - How to Use the php function ssh2_sftp_rmdir
Article
The ssh2 library offers some pretty handy functions that simplify most file system operations. ssh2_sftp_realpath(a,b) for example transforms a file name to the real effective path at the remote file system. ssh2_sftp_rmdir is another useful function to remove folders on the server.
Other functions that I found interesting are ssh2_stat(a) and ssh2_getcmd(a) that let you get some info about the file like last access time or permissions (in octal). I also found ssh2_exec very useful as it lets you execute a shell command on the remote server.
If you are new to ssh2 you should read the Getting Started with SSH2 in PHP documentation page. It is very well written and contains a lot of examples that help you understand the different functions.