0

I need a function to extract the link (url) from a hyperlinked text in PHP. For example i get it a string and it returns me the link or url.

Thanks before for your answers...

closed as off-topic by TheDeadMedic, s_ha_dum Jun 25 '15 at 14:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

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

Note that, SimpleXMLElement required PHP version above 5.

  • Thanks a lot, it's perfect but I have this warning: Warning: Illegal string offset 'href' in url... – ali Jun 25 '15 at 10:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.