Mercifull Posted February 28, 2007 Share Posted February 28, 2007 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 :) 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 Link to comment Share on other sites More sharing options...
____ Posted February 28, 2007 Share Posted February 28, 2007 Unless you've got some reason to do it that way - wouldn't it just be easier to use an XML file? Link to comment Share on other sites More sharing options...
Mercifull Posted February 28, 2007 Author Share Posted February 28, 2007 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. 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 Link to comment Share on other sites More sharing options...
____ Posted February 28, 2007 Share Posted February 28, 2007 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. Link to comment Share on other sites More sharing options...
Mercifull Posted February 28, 2007 Author Share Posted February 28, 2007 Im not going to pretend i know what im talking about here, Rick, so some links for help would be good lol 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 Link to comment Share on other sites More sharing options...
runesmithie Posted February 28, 2007 Share Posted February 28, 2007 Could you use a regex to do it? /total=(\d+);good/ I just posted something! ^_^ to the terrorist...er... kirbybeam. Link to comment Share on other sites More sharing options...
____ Posted February 28, 2007 Share Posted February 28, 2007 <?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." "; } ?> Link to comment Share on other sites More sharing options...
Mercifull Posted February 28, 2007 Author Share Posted February 28, 2007 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]; ?> 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 Link to comment Share on other sites More sharing options...
Mercifull Posted February 28, 2007 Author Share Posted February 28, 2007 In action on the front page of the Battlestar Wiki Cheers Rick. 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now