Author Topic: [SOLVED] substring help!!!  (Read 2808 times)

0 Members and 1 Guest are viewing this topic.

Offline ilkernycTopic starter

  • Irregular
  • Posts: 2
    • View Profile
[SOLVED] substring help!!!
« on: November 02, 2007, 11:05:29 PM »
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
« Last Edit: November 02, 2007, 11:07:22 PM by ilkernyc »

Offline MadTechie

  • Guru
  • Freak!
  • *
  • Posts: 9,374
  • Gender: Male
  • I try to F1
    • View Profile
Re: substring help!!!
« Reply #1 on: November 02, 2007, 11:11:38 PM »
better to use RegEx..
see Regex Section

example code
Code: [Select]
<?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 ;
?>
Computers are good at following instructions, but not at reading your mind.
The quality of a response, is usually directly related to the quality of the question. ©2009 mjdamato
I dunno about that.  A regular expression has a 0% chance of touching my penis.
the code is professionally made up but not working
Remember to Click Solved, how to ask questions - the smart way

Offline ilkernycTopic starter

  • Irregular
  • Posts: 2
    • View Profile
Re: [SOLVED] substring help!!!
« Reply #2 on: November 04, 2007, 01:44:39 AM »
thanks a lot!