How to Extract an HREF from a String in PHP

An example on how to get the href from a string using PHP Function SimpleXML.

In order to extract an href from a string in PHP we can use the PHP Function SimpleXML. 

How To: 

$a = new SimpleXMLElement('<a href="www.thecodebeast.com">Click here</a>');
echo $a['href']; // will echo www.thecodebeast.com

Enjoy!