Jump to content

[SOLVED] substring help!!!


ilkernyc

Recommended Posts

Hi,

 

i want to get the url string out of the href. For example this comes back from the database:

 

a href="http://something.com" target="_blank" /a

 

i want to get the substring "http://something.com" How do i do it?

 

Thank you so much for your helps

 

Note: Url's are in different lenghts in the database

Link to comment
https://forums.phpfreaks.com/topic/75870-solved-substring-help/
Share on other sites

better to use RegEx..

see Regex Section

 

example code

<?php
$html = '<a href="http://something.com" target="_blank">Test </a>';
if (preg_match('/href="([^"]*)"/i', $html , $regs))
{
$result = $regs[1];
} else {
$result = "No URL Found";
}
echo $result ;
?>

Link to comment
https://forums.phpfreaks.com/topic/75870-solved-substring-help/#findComment-384004
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.