Jump to content


Photo

**SOLVED** Strings


  • Please log in to reply
3 replies to this topic

#1 0p3n_p0rT

0p3n_p0rT
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 March 2006 - 04:30 PM

Hey, I have something along the lines of this:
<?
$string = "

<html>
<title>sitename</title>
<FRAMESET ROWS="*,0" COLS="100%" border="0">
<FRAME SRC="do.php?d=XQE2VILT&l=en" noresize>
<FRAME SRC="s.php" noresize scrolling="no">
</FRAMESET>

</html>";
?>

And I want to extract just the "do.php?d=XQE2VILT&l=en" part. However, the querystring is random, and the length of this this may differ. I have tried various substr, strchr, etc. etc. and cannot extract that certain bit.

Can anybody help?

Thanks,
0p3n_p0rt.

#2 Hooker

Hooker
  • Members
  • PipPipPip
  • Advanced Member
  • 193 posts
  • LocationWales, UK

Posted 04 March 2006 - 05:54 PM

do you want all of do.php?d=XQE2VILT&l=en" or the "XQE2VILT" and "en" bits?

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 04 March 2006 - 09:30 PM

Assuming you always have "do.php",

$p1 = strpos($string,'do.php');
$p2 = strpos ($string, '"', $p1);

$result = substr ($string, $p1, $p2-$p1);

echo $result;

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 0p3n_p0rT

0p3n_p0rT
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 March 2006 - 11:01 PM

Thanks, that was great!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users