[solved] coding problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

[solved] coding problem

Post by jabbaonthedais »

Solved this problem
I've been working on this for some time. I need a script that can get urls and link descriptions from a html page, so I can post some of them in order.

Code: Select all

$da = fopen("$url","r");
$str = fread($da, 1000000);
preg_match_all("|<a[^>]*>(.*)</[^>]+>|U", $str, $m, PREG_PATTERN_ORDER);
preg_match_all("|http(.*)'>|U", $str, $d, PREG_PATTERN_ORDER);

print "<b>Link descriptions:</b><br>";
echo $m[1][25];
print "<br>";
echo $m[1][26];
print "<br>";
echo $m[1][27];
print "<br>";
echo $m[1][28];
print "<br>";
echo $m[1][29];
print "<br>";
echo $m[1][30];
print "<br>";
echo $m[1][31];
print "<br>";
echo $m[1][32];
print "<br>";
echo $m[1][33];
print "<br>";
echo $m[1][34];

print "<p><b>Links:</b><br>";
echo $d[0][25];
print "<p>";
echo $d[0][26];
print "<p>";
echo $d[0][27];
print "<p>";
echo $d[0][28];
print "<p>";
echo $d[0][29];
print "<p>";
echo $d[0][30];
print "<p>";
echo $d[0][31];
print "<p>";
echo $d[0][32];
print "<p>";
echo $d[0][33];
print "<p>";
echo $d[0][34];
print "<p>";
?>
This code brings back a blank page. Yet, when I put $m[1][0] and $d[0][0] by themselves, it brings back the first links. I can go all the way to the 14th link, then they don't work. Yet, there are over 50 links in the page.

Any ideas?
Post Reply