How to extract link when given partial link value

Posted by mrjames on Stack Overflow See other posts from Stack Overflow or by mrjames
Published on 2010-05-07T21:43:26Z Indexed on 2010/05/07 21:48 UTC
Read the original article Hit count: 220

Filed under:

hi, I am using PHP 4, that is what the host has at the moment. How can I extract link from a string when given part of the link to find.

Example
$find_string = 'http://www.mysite.com/apple';
$string = 'Something and something else < a href="http://www.mysite.com/apple_banana">testlink< /a> something else and so forth < a href="http://www.mysite.com/orange">orange< /a>

In this case I would like to extract only the links that has http:// www.mysite.com/apple in it so it would retrieve http://www.mysite.com/apple_bananan

Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about php