I have my application to allow users to write comments on my website. Its working fine. I also have tool to insert their weblinks in it. I feel good with contents with their own weblinks.

Now i want to add rel="nofollow" to every links on content that they have been written.

I would like to add rel="nofollow" using php i.e while saving data. 

So what's a simple method to add rel="nofollow" or updated rel="someother" with rel="someother nofollow" using php

a nice example will be much efficient