Please login or register.

Login with username, password and session length
Advanced search  

News:

(2009-05-04) The Rules and Terms of Service have been updated. Please make sure you read, understand, and follow them.

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

0 Members and 1 Guest are viewing this topic.

ilkernyc

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

MadTechie

  • PHPFreaks Recommended
  • Freak!
  • *
  • Online Online
  • Gender: Male
  • Posts: 7,199
  • I try to F1
    • View Profile
Re: substring help!!!
« Reply #1 on: November 02, 2007, 10: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 ;
?>
Logged
Computers are good at following instructions, but not at reading your mind.
After all, why would you insert your penis into a hole for no reason whatsoever?
he's nucking futs.
i can't see why my own 'home brew' method should be any more crackable than an md5 hash.
Remember to Click Solved, how to ask questions - the smart way

ilkernyc

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

PHP Freaks Forums

 
 
 

Page created in 0.045 seconds with 19 queries.