Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Pulling text from an external html file (not runescape!)

Featured Replies

Ok so ive got a page on my webserver which dynamicly generates statistics in the following style:

 

 

 

total=0;good=0;views=0;edits=0;users=0;admins=0;images=0;jobs=0 

where 0 is a number between 0 and well.. infinite really but no more than a 7 digit number really.

 

 

 

 

 

 

 

I want to be able to pull the total number from this file and display it on another php page using cURL or file_get_contents but im totally lost by it and cant find a tutorial thats any good for me.

 

 

 

 

 

 

 

I want the number between total= and ;good=....etc anod nothing else so I need to strip all the other stuff.

 

 

 

 

 

 

 

I worked out how to use file_get_contents to get a certain number of characters after a string such as total= but because I cant guarantee what the length of the number is the script varies between 13337 (total=13337;good=....) and 96;go (total=96;good=....)

 

 

 

 

 

 

 

I need the script to start after total= but stop before ;good= Some help would be really appreciated :)

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Unless you've got some reason to do it that way - wouldn't it just be easier to use an XML file?

  • Author

Well im not an expert on this. All i know is that I need to pull off a number from a file this file and display the figure somewhere else.

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Ah, the wiki; hrm.

 

 

 

 

 

 

 

Well, you could fetch all the text, explode using ; for the delimeter and str replace a-z and = with null value then you'll be left with your integer values only in the array.

  • Author

Im not going to pretend i know what im talking about here, Rick, so some links for help would be good lol

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Could you use a regex to do it?

 

 

 

 

 

 

 

/total=(\d+);good/

smithie3.jpg

I just posted something! ^_^ to the terrorist...er... kirbybeam.
<?php



$urlofstats = "rawstats.txt";



$rawstats = file_get_contents($urlofstats);







$num_values = explode(";", $rawstats);







$remove = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","=");



foreach($num_values as $x => $value)



{



  $num_values[$x] = str_replace($remove, "", $value);



}







/* print out the values and [cabbage] */







foreach($num_values as $value)



{



  echo $value."

";



}



?>

  • Author

Thanks to Rick here is the final code I used:

 

 

 

 

 

 

 

<?php



$urlofstats = "http://en.battlestarwiki.org/wiki/Special:Statistics?action=raw";



$rawstats = file_get_contents($urlofstats);







$num_values = explode(";", $rawstats);







$remove = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","=");



foreach($num_values as $x => $value)



{



  $num_values[$x] = str_replace($remove, "", $value);



}







echo $num_values[1];







?>

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

  • Author

In action on the front page of the Battlestar Wiki

 

 

 

Cheers Rick.

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.