title: php convert all links to absolute urls
body: <p>I am writing a website crawler in php and I already have code that can extract all links from a site.
  A problem: sites use a combination of absolute and relative urls. 
  Examples (http replaced with hxxp as I can't post hyperlinks):</p>
  
  <p>hxxp://site.com/</p>
  
  <p>site.com</p>
  
  <p>site.com/index.php</p>
  
  <p>hxxp://site.com/hello/index.php</p>
  
  <p>/hello/index.php</p>
  
  <p>hxxp://site2.com/index.php</p>
  
  <p>site2.com/index.php</p>
  
  <p>I have no control over the links (if they are absolute/relative), but I do need to follow them. I need to convert all these links into absolute URLs. How do I do this in php?</p>