Jump to content

Echoing a certain part of a text held inside a div


Bikkebakke

Recommended Posts

Hello again, Freaks!

 

I stumbled upon a rather tedious problem that I've been trying to solve for quite some time now.

 

I play this browser-game which includes a lot of clicking so I made a menu (simple page that consists of two frames, one for the menu and one for the game itself) that holds links and forms to lessen the clicking on the actual game.

 

Now I've been trying to find a way to echo my characters HP etc. from the games profile-page to the menu but I can't access my profile-page with file_get_contents();, because it's required to be logged in to see the page.

 

So, after burying that idea I got a new one: Loading the profile page inside the menu frame as a hidden div that reloads every now and then, but I don't know how to find and echo the parts of text I want to, so if anyone could help me on how to echo a certain part of text on the same page the code is ran?

 

Sorry if I was confusing, feel free to ask for more details if needed,

- Bikkebakke

I really doubt I need that advanced stuff, all I need to do is pick a part of text, the first method I tried was:

 

<?php
$contents = file_get_contents('http://www.example.com');
$term_search="Search_term";
$no_term=1000;
$pos=strpos($contents, $term_search);
$pos += strlen($term_search);
$new_pos = substr($contents,$pos,$no_term);
echo $new_pos;
?>

 

But as of now I don't get the content from another location but from the very same file.

So like, is there a way to find text from the same file?

I.e.

<html-stuff>
<div that loads an page in it>
<more html-stuff>

<?php
//$fetch = script to fetch the contents of the previously mentioned <div>
echo $fetch;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.