I am trying to learn to Parse a document and here is the script that i am using to read the file, which is a directory listing from a nother server:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
function file_get_contents($filename)
{
$fp = @fopen($filename, "r");
if (!($fp))
{
return 0;
}
while (!feof($fp))
{
$temp .= fread($fp, 4096);
}
return $temp;
}
if ($getcontents) {
$contents = file_get_contents($filename);
echo $contents;
} else {
?>
<form name="form1" action="<?php $php_self ?>">
<p>
<input name="filename" type="text" id="filename" value="http://">
<input type="hidden" name="getcontents" value="1">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<?php
}
?>
</body>
</html>
[/color]
Here is a little of what the file will expect to read like ($contents that is):
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Index of /woodrack/bars</TITLE>
</HEAD>
<BODY>
<H1>Index of /woodrack/bars</H1>
<PRE><IMG SRC="/icons/blank.gif" ALT=" "> <A HREF="?N=D">Name</A> <A HREF="?M=A">Last modified</A> <A HREF="?S=A">Size</A>
<HR>
<IMG SRC="/icons/back.gif" ALT="[DIR]"> <A HREF="/woodrack/">Parent Directory</A> 05-Nov-2002 18:52 -
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="2buttersflowerbar.gif">2buttersflowerbar.gif</A> 26-Jul-2001 08:46 20k
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="HrsLine09.gif">HrsLine09.gif</A> 31-Oct-2000 12:21 5k
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="Pink_Pole.gif">Pink_Pole.gif</A> 10-Jul-2000 00:25 4k
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="Pink_Pole2.gif">Pink_Pole2.gif</A> 10-Jul-2000 00:26 4k
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="blufloralbar-1.gif">blufloralbar-1.gif</A> 23-Jun-1999 16:57 5k
<IMG SRC="/icons/image2.gif" ALT="[IMG]"> <A HREF="britetwistline3.gif">britetwistline3.gif</A> 05-Jun-2000
I have a few books that I am reading on PHP, but they are all very light on the subject parsing with such calls as substr but I need to be able to extract out of:
<A HREF="britetwistline3.gif">britetwistline3.gif</A>
ONLY the
britetwistline3.gif portion, and so on for all of the links listed.
This is to allow me to extract files from a specified server where I need to grab ALL of the files to move/copy them. I do not want to use FTP since ultimately this will be a script used by others on MY server. I don't want to allow them access to their account via FTP. These accounts are going to be for WebTV users, they don't have any type of FTP support anyway.
All help on extracting very specified sections of data would be appreciated. The problem that I am having is creating the array by looping and reading the data in $contents (in this case) and populating that array.
Thanks.