Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Reading In A Part Of A HTML File


I am working on a script at the moment, and I want to be able to include some HTML snippets that a user can update at any given time.

In most cases the snippets will be only a table, but I want to make allowances for the file if it is a full HTML file.

What I would like some help in working out, is what would be the best way to read in the file and take all the code after the <body> tag upto but not including the </body>. Is there an eay way of doing this? So that if all I want is the table that is inside the page, that is all I will get.




View Complete Forum Thread with Replies

Related Forum Messages:
Reading Part Of A File
I would like to read say... ONLY the last 200 bytes of a REMOTE, BINARY file. How can i do this?

View Replies !
Including Part Of An HTML File
Is it possible to include part of a file without including the whole thing?

View Replies !
Read Part/top Of A Remote Output Html File
I'm using file_get_contents{URI) to read/use data in my scripts.

View Replies !
Reading An HTML File, Matching Between Tags, Into An Array
I have an HTML file that I want to read.

In the file there are maybe 2000 cases of the following:

<FONT COLOR="#660066">X</FONT>

The color number changes however so instead of 660066 it may be sometimes FFFFFF, etc.

Anyways this line identifies above the "X" which I want to extract in each case (all 2000) and then I suppose I need to read them into an array then I can output them all without the font color info before and after them in one big long list.

View Replies !
Getting Part Of Another HTML Page
I'd like some help with writing a script that grabs part of another HTML page. For example : I want to grab the content of a HTML page that contains the following strings :

<!-- begin --> and <!-- end -->

Then I want to get all the content (including these two tags) that is in between the two tags.

View Replies !
Get PART Of A File (via ID)
So I want to get part of a file, specifically everything WITHIN the div id="left". I have this code, but it gets the whole file. I want to use this to edit a remote file test.html). Code:

View Replies !
Php Form To Allow The User To Enter Part Of A Last Name And/or Part Of A First Name To Display The Data
I'm sure this is not a hard thing to do, but for some reason I can't get my mind to figure this out. I have a database with Name, Address, and Car Type tables. 

I'm just trying to do a simple php form to allow the user to enter part of a last name and/or part of a first name to display the data in the tables. My brain has twisted around this and I cannot figure it out.

View Replies !
Reading HTML Title In PHP
I am challenged with the task of writing a PHP script that will prompt the user for a website (ex: yahoo.com). When submitted, the PHP script will somehow open the web page as a file, somehow search the source, find the <title> tag, and return the title of the web page..

If someone knows an easier approach to this, I would appreciate it. Opening an entire website as a variable seems like a bit of overkill..

Heres where I'm at so far, I'm kind of looking for a push in the right direction. I've been googling for awhile now trying to find out how to tackle this, but searching for things like "php, website, title, web page, HTML" hasn't proved too successful..

<?php

// Assigns $site from the form text box named "site"
//
$site = $_POST['site'];

$file = fopen($site, "r");

// This needs to open the text-source of the inputted webpage.  
// From here I will search for the <title> tag in the HTML...
//
echo "$file";
echo "<br><hr>";

?>

View Replies !
Reading HTML Documents
I need to have the ability to use PHP to read HTML document on other sites to find out if my link is in place on their site. I have searched the internet for this information, but the only thing that comes up is reading XML documents.

View Replies !
Searching For A File If I Only Part Of The Name
Using PHP 4.4.4.

What is the easiest way to return the full path of a file if I know
the directory it is in and the beginning part of the file (it will
begin with the word "header")?

View Replies !
Small Part Of Txt File
Im trying to get information from a txt file using two different arrays. I want to store line 1 of the txt file in one array and line 2 to 7 in another array. how i can get started on this?

View Replies !
Part Of A Remote Txt File
the following code returns 2 different things, the correct $filesize (9425) from the header and only part of the text file into $data (2491 bytes)unfortunately, i cannot give out the user and pass. all i can say is that when i run it on my apache server locally, it reads the entire file properly. The split on the remote site occurs between the numbers 1 and 4 in "14", so i have no idea what trips it up.

$filename = 'http://user:pass@mysite.com/testfile.txt'
$ary_header = get_headers($filename, 1);
$filesize = $ary_header['Content-Length'];
$fh = fopen($filename, 'r');
$data = fread($fh, $filesize);
fclose($fh);
echo $filesize . "<br />";
echo strlen($data);

any ideas?

View Replies !
Read Part Of A File
I'm reading this huge text file and I want to start reading from a specific point.
lets say a line in my file is like this
[11/20/2006 12:07:12 AM] abcdel defg0 msping (timeout - 2000 ms)

and i want to start reading from a specific date to a specific date. how would I go about doing that using php?

View Replies !
Get Only Part Of The Remote File?
Is there anyway that I can use curl to retrieve only n bytes/characters
of a file? I want to get some certain information on a remote site, and
the data I need stays somewhere at the middle of the page, so I dont
need to retrieve the whole page, which can save me lots of time.

View Replies !
Appending To A Certain Part In The File
$myFile = "testFile.html";
$fh = fopen($myFile, 'a');
$stringData = "$whatuwrote";
fwrite($fh, $stringData);
fclose($fh);

Something like that, Do you know how to put that into the middle of a file instead of writing it at the bottom of the page.

Example:
echo "hey";
echo "APPEND HERE";
echo "hey";

View Replies !
Reading HTML Table Values
So I have a webpage I'm working on that uses javascript and PHP to manage a table that contains rankings. The users selects, using radio buttons, their top 5 specializations. As they are selected they are inserted into an HTML table at the base of the page using javascript.

My question is,  I want to save these values into a mysql table when the save button is clicked and I need to be able to pass the current value sin the table to php variables so I can use them in mysql queries.

View Replies !
Reading HTML Table Like Excel Does
If I open a text file that consists of a simple HTML table then Excel with display the TR and TD as rows and columns like it would a CSV file. Is there any way to parse an HTML table using PHP in a similar fashion to this as I can with fgetcsv()?

The file is kind of big so running it through a big preg_match_all() doesn't look feasible memory wise.

View Replies !
Include Part Of A Text File
I have a text document that stores text for use in a flash movie. I'm
also using PHP to displace the same text on another page. However the
text document includes 2 tags for use by the flash movie... title= and
&content= ... see text file at end of post ....

when i use the php command <?php include ("info.txt"); ?> it also
displays those tags. Is there any way to use php to just display what
apprars after the &content= in my text file.

I can't remove the tag begause it is required for the flash file
elsewhere on the site.

"
title=CDN HOME &content=The COMPUTER DONATION NETWORK is a resource of
new, used and refurbished computer equipment, software, networking gear
and lab furnishings for "

View Replies !
Include Part Of The File Isn't Working
i have a menu.inc file that i want to use on multiple pages and one of the pages can be found at http://members.aol.com/itsjojofasho/home2.php but for some reason, the include part of the file isn't working when i upload it. but it works when i'm working offline on my computer.

View Replies !
Grab The ID From The DB And Pass It To Be Part Of The Renamed File
I have another file that copy a template from a folder (here for the example: footer.php
to another folder within that folder where now is the new copied "footer.php" I run the following script Which results in "No such file et..." The idea behind $ID is that the new file got to be have a different name than other similar files And got to be unique so I grab the ID from the DB and pass it to be part of the renamed file Well it does not work as planned.

<?
$rename=$id;
$file_name = footer.php;
$read_extension = explode(".", $file_name);
$ext = $read_extension[1];
$renamed = $rename.".".$ext;
rename($file_name, $renamed);

?>

View Replies !
Reading HTML Unordered List Into Multidimensional Array
I have some software (Wordpress, actually) that is sending HTML code of an unordered list when I call a particular function. I want to make that list into a multidimensional array. So something like this: Code:

View Replies !
Anyone Have Any Tips On Reading Word .doc Files To Convert To Html/pdf
I'm trying to make word .doc files into .pdf or .html files for a site for ease of use, and I wanted some tips/ or if someone knows a script.

View Replies !
File Locking / File_get_contents() / File Changed While Reading?
I'm using file_get_contents() to get the contents of a file, *BUT* I need to be sure that the file doesn't change while file_get_contents() is reading the contents of the file.

I'm not sure if file_get_contents() will ensure that the file contents don't get changed ( another script fwrites() to the file ) while file_get_contents() is doing its thing, or if I need to use a lock file to ensure this doesn't happen.


Anyone know if I need to use a lock file, or will I be fine just calling file_get_contents()?

View Replies !
Reading A File - Open A File Just Copied
For some reason I can open a file, but I can't read it (I checked with is_readable() and is_writeable() and both returned true). I'm trying to open a file just copied, so maybe that's the reason why I can't read it, and I would have to reload the page. PHP Code:

View Replies !
HTTP File Reading HTTPS File
I need a way to read https php file that returns me a xml data. I must read from a http php file. These two files are on diffrent domains and a https php file uses openssl. Has anyone tried or done to do such thing? I assume I have a problem because these two files are not on same domain or these two files could be on a diffrent domains if certificate would be paid - verified.

View Replies !
Need A .txt File To Become Part Of A Php File.
I need a .txt file to become part of a php file. Not just as txt, but as php.

View Replies !
Reading Tar.z File
i wanna extract and read data from a tar file i have tried www.phpclasses.org/browse/package/529.html thing. but that is not working for .z file. any idea how to do that ?

View Replies !
Reading A File
I've got the following script:

<?
$inhoud = file("/opt/scripts/sc/sc_trans.log");
$inhoud = implode("", $inhoud);

$inhoud_array = explode("
", $inhoud);

for($i=0; $i < count($inhoud_array); $i++){
$titel1 = explode("[DECODE] Opened ",$inhoud_array[$i]);
$titel2 = explode(".mp3",$titel1[1]);
$titel = $titel2[0];

$part1 = explode("<",$inhoud_array[$i]);
$part2 = explode(">",$part1[1]);
$tijd= $part2[0];
$tijd= ereg_replace("@"," ", $part2[0]);

echo "[$tijd] $titel
";
}
?>

While running this I get:

PHP Notice: Undefined offset: 1 in /opt/scripts/shoutcast/crphp on
line 9

How do I solve this?

View Replies !
Reading A .txt-file With Php
I have the following problem and it would be nice, if someone could help
me out on this problem:

content of file.txt

#1: Michael
#2: Dennis
#3: Karl

the following file writes only the first line of file.txt:

<?php
$fp = fopen("file.txt","r");
if ($fp)
{
$line = fgets($fp, 100);
echo "$line<br><br>";
fclose($fp);
}
?>

Now I would like to have a PHP-file, which can write every line in
different orders (the order should be write in the PHP-file)

for example:

#2: Dennis
#1: Michael
#3: Karl

View Replies !
Reading A M3u File
I'm trying to read a .m3u file.. I'm almost done but got one problem.. I'm trying to remove every non related info for the song info.. meaning the #EXTINF: etc... I've managed to strip the #EXTINF but the problem comes to removing the number after that... Code:

View Replies !
Not Reading Whole File
I have the following code after uploading a csv (text) file:

   $file = fopen($_FILES['theFile']['tmp_name'], 'rb') or die("Can't open file");
   $theData = fread($file,filesize($_FILES['theFile']['tmp_name']));
   fclose($file);

   $delimiter = "
";
   $splitcontents = explode($delimiter, $theData);

for whatever reason, its not reading more than two lines.. it has about 12,000 lines in it, and needs to be split by the " " then I loop through that array and split it by the "," its only reading the first 2 lines. what am I doing wrong?

View Replies !
Not Reading The Php.ini File
I have php 4.3.3 on my local IIS5.1 server (XP) in ISAPI mode. It all works ok except that it does not seem to be reading the php.ini file as any changes I make are not shown up when doing a phpinfo(). This shows the ini path as c:windowsphp.ini. This is where it is and it is the only php.ini
on the machine. I have tried stopping and starting the service but this does not help.

View Replies !
File Reading
<a href="http://localhost/Ad/img_1.jpg" target="_top" >
<img src="Ad/img_1.jpg" width="468" height="80" border="0">
</a>
~
<a href="http://localhost/Ad/img_2.jpg" target="_top" >
<img src="Ad/img_2.jpg" width="468" height="80" border="0">
</a>
~
<a href="http://localhost/Ad/img_3.jpg" target="_top" >
<img src="Ad/img_3.jpg" width="468" height="80" border="0">
</a>


how can i extract "href" & "src" elements from the text file and store into an array?

View Replies !
Reading A .prn File
I have one prn file which contains chinese data that i want to read using php and then insert the values in database.

View Replies !
Reading File
I need to read a file that looks like this:

g1.jpg::Description #1
g2.jpg::Description #2

I need each side of that "::" to be a different variable and I need it in some kind of while loop till the end of the file. I've tried a coupld of split and explode versions and can't get it going, basically because of that end of the line when it starts a new one. This file displays descriptions for pictures in another script, and it splits it by of course as you can see the file name then the "::". But since I'm not reading the file list I can't get that other splitter.

I don't want to read the directory list because in case the file isn't there anymore I don't want that to conflict with reading the file out and displaying the contents. Basically what I want to do is have an input box for each one, and then at the end of the php file allow the user to click on save to save it back to the file if they edited anything.

View Replies !
Reading From A File
I know how to read form a file and get everything from inside the file, but now how would I use the variables from inside the file? PHP Code:

<?
$vf= "vars.php";
$gvf = fopen($vf, 'r') or die("Cant read from file");
$gv = fread($gvf, filesize($vf));
fclose($gvf);
?>

View Replies !
Reading From File
I have following code for putting contenst of a file into a web page:

<?php
$filename = "../msd/news.txt";
$handle = fopen ($filename, "r");
$content = fread ($handle, filesize($filename));
fclose($handle);
echo ($content);
?>
But in file news.txt I have formating that is not showing, but
interpreting.
For example, in that file there is:
<a href="link.php">link</a>
End result is hyperlink.

View Replies !
Reading And Writing From A File?
How would I go about reading and writing from a file? I would like to make a Web GUI for my sendamail virtualhosts.

View Replies !
Problem Reading From File
I have used this code in other projects, however, I'm geting an error that I don't understand.

Here is the error:

View Replies !
How To Open A File For Reading ?
i want to open a text file for reading. i tried this but nothing comes out ?

$fp = fopen("/u/htdocs/privat3/ttt/test.txt", "r");
fputs($fp, "GET ".$url." HTTP/1.0 r ");

View Replies !
Reading File Properties
I am trying to create a dynamic page that reads a user's browsing history and writes itself according to that. How can I use php to determine the properties of files?
Any ideas would be helpful.

View Replies !
Reading Only One File From Directory
I am trying to make a class that does a bunch of file stuff and one of the functions is suppose to read the files out of the directory. PHP Code:

View Replies !
Reading Img File From ISAPI .dll URI
Advice or references to information appreciated...

I would like to capture an image file that results from a URI ending with a .dll extension. I assume the .dll conforms to ISAPI but I don't know much about that yet. The big picture is that I want to capture a third party dynamically generated image (chart) normally displayed in a webpage and cache it on a PHP based server as a static image file (.gif, jpeg, or other).

Any suggestions or references to discussions of this would be appreciated. I'm new to PHP but with a long history of C/C++ and Java coding.

View Replies !
Reading File Contents
I am parsing a file delimited by |. For some
reason the content is displayed to the browser properly - but the loop
is consistenlty outputting "one more row" of just the titles.
Perhaps I'm going about it completely wrong:

<?php

$filename = 'books.file'
$fp = fopen("$filename", "r");

while (!feof ($fp)) {
$contents[] = explode("|", fgets($fp, 4096));
}
fclose ($fp);
$loop=1;
foreach ($contents as $row) {
echo "<b>$loop</b> -------------------<br>";
echo "<b>Reviewer</b>: $row[0]<br>";
echo "<b>Date</b>: $row[1]<br>";
echo "<b>Title:</b> $row[2]<br>";
echo "<b>Author:</b> $row[3]<br>";
echo "<b>Rating:</b> $row[4]<br>";
echo "<b>Comments:</b> $row[5]<br><br>";
$loop++;
}

echo "<a href="bookreview.html">Insert a new book review</a>";

?>

View Replies !
Reading File Into Array
I have a directory which contains files and I have since found out that I can place the files into an array. However, I am new to all of this and my all attempts at writing correct code have failed.

All I want to do is place the file name into the array so that I can create a while loop on the array in a table. I would even be satisified with counting the number of files in the directory.

View Replies !
Reading Zip File Contents
say i have a zip file - test.zip - with a file - somefile.txt - in it,
whose contents are as follows:

this is a test

when i try running the following script on the above zip file, i get
everything i should be getting, save for the contents of somefile.txt
(example output follows the script):

<?
$filename = 'test.zip'
if (($temp = zip_open($filename))) {
while ($entry = zip_read($temp))
if (preg_match('/.txt$/',zip_entry_name($entry))) {
print "file name = '".zip_entry_name($entry)."'
";
print "file size = '".zip_entry_filesize($entry)."'
";
print "contents = '".zip_entry_read($entry)."'
";
}
zip_close($temp);
}

?>

the output is as follows:

file name = 'somefile.txt'
file size = &#3914;'
contents = ''

the output i would like and expect is as follows:

file name = 'somefile.txt'
file size = &#3914;'
contents = 'this is a test'

View Replies !
Reading Https File
I have a screencraper application that read webpages with fopen() and then
processes them.

Now I found a https page that does not require a password. However, I cannot
read it with fopen().

My question is: are there other ways to read this page? Or is it technically
impossible?

View Replies !
Reading A File Into An Array
I am reading a file into an array. Each line is working as a seperate record in the database. The fields are comma deliminated. I can get it to read the fields, one by one, and print them to the user...

how can I sort them by one of these fields, yet make sure that all the other information for each record remains associated with the sorted data? It needs to be outputted to the user in order.

View Replies !
Reading From A Blob Or A File Which Is Better?
I have over 5000 thumbnail pictures of size 5kb each. I would like to
able to load all 5000 pictures and view 50 per page using
mysql_data_seek(). I would like to know what are the advantages and
disadvantages of using a MySQL blob field rather than reading the
images directly from the file? How does one insert an image into a
blob field? Can it be done dynamically?

View Replies !
Reading MSword File
can anyone suggest me how the content of MSword document can be read and put in mysql database.

View Replies !
Why The Need To Flock() When Reading A File?
I'm only going to be opening and reading a text file. I understand there's the syntax:
flock($fp, 1) for reading file. My question is, is this even necessary, provided my script does not write to a file elsewhere?

View Replies !
UTF-8 File Reading And Writing For PHP
I'm creating a page that:
- accepts user input in whatever language
- saves that input to a file
- reads the file and displays the original input

The following code successfully writes the user input to a file (when I
open the file, it's in the correct font), but I can't get PHP to read
the file and display the correct characters.

HTML --------------- Form
<FORM name=saveform method=post action="wiki.php">
File:
<TEXTAREA name=thetext rows=20 cols=30></TEXTAREA>
</TEXTAREA>
<INPUT type=submit>
<INPUT type=hidden name=action value="save">
</FORM>

PHP --------------- Sticks the data in a file
$message = $_REQUEST['thetext'];
echo $message; // This displays the correct stuff
$filename = "tmp/tmp.txt";
$fr = fopen($filename, "wb+");
// adding header
fwrite($fr, pack("CCC",0xef,0xbb,0xbf));
fputs($fr, $message);
fclose($fr);

PHP --------------- Read the data from the file
$thefile = file($filename);
array_shift($thefile); //To get rid of the BOM
$ret = "";
foreach ($thefile as $i => $line) {
$line = rtrim(utf8_decode($line));
$ret .= $line;
}
echo $ret; // This _doesn't_ display the correct stuff

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved