Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get a specific amount of code from a html file

Status
Not open for further replies.

lukelukeluke

Technical User
Joined
Dec 23, 2003
Messages
117
Location
CH
Hi there!

What i wanted to do with php was to get something from a file. Ive seen that earlyer in another programming alnguage that there is an option with the name "html ignorebefore" and "html ignoreafter".

example of a html document "example.htm":
<html><header></header><body>My Name is Jack</body></html>

What i would like to do now is "taking jack outside of the document" and into a variable into my current php document. Is there a function like these html ignorebefore or ignoreafter?

Thanks alot for help!

Best regards,
Luke
 
thanks for youre answer, but:

I look for something to get a specific information out of a htm site.
such as i told where i can enter whats before it and whats after it and it will give me whats between.
But this has to work for a site, for a file, not for a var....
 
for 1 . .your question doesn't involve php which isn't cool since this is a php forum .. but i think you are going to want to use php to send the variable to different pages ... like

name.html
Code:
<p>Enter Your Name: <form action="stuff.php" method="post" name="stuff">
Enter Your Name: <input name="name" type="text" value="">
<input type="Submit" name="submit" value="Enter Name ">

name.php
Code:
//this line gets the posted value from the last page and puts it into a variable called $name
<?php 
$name=$_POST['name'];
echo "Welcome $name";
?>

this answer your question?

If programming were as fun as cycling, then we'd need more bike mechanics.
 
i think no one understands my question, well, sorry for my bad english.

What i want to have is a script, which can read a text, and after take something outside of the text inside a var, where you can define what comes before that and what comes after.
For example i have the file "test.html" with the following content which is a static document:
"<font>Hello everyone and welcome to our ocntest.</font></td></td><font>This year we have the biggest blah....</font>"

So this is my document. Now i would like to create a php file where i can say:
"php: Please read the document test.html for me and give me in a variable what come after "t>Hello everyone and " and before " to our ocntest.</font></t"

Php should take welcome into the var.
But im not able to edit the html document because its on another server. What i want is to take a specific area of html code out of another static html document.

Anyone knows?
 
You would need to open a connection to that server using fsockopenn() and retrieve that page. Then once the page is in memory, use strip_tags or regex to remove all but the data you need. Then you can do what you want with it...

Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top