Jump to content

[SOLVED] 2 Minute question


liamthebof

Recommended Posts

Ok, I know this is simple as I have dont it before but have long forgot how.

 

SIimplified, I have a test file:

information.txt

Some useless data in this file

Crap here score=174

rolls=8343

other crap

total=17

 

I need to be able to get the value of rolls by going to the 3rd line, and 7th - end of line characters resulting in me attaining the value 8343.

I cant count characters from the top of the file as the vlue of score chnage between 2, 3 and 4 figure numbers.

 

Any help is appreciated,

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/117521-solved-2-minute-question/
Share on other sites

Actually, with further testing I am having problems though your code did work for my example.

 

I will post the actually data I am using:

 

'http://atlanta.rollinpatrol.com/stats/getstats.php?nickname=[RP]Capop'

 

I am using that external data source and I need to attain the value of Kills.

 

Using

<?php

 

$strFile = "http://atlanta.rollinpatrol.com/stats/getstats.php?nickname=[RP]Capop";

$arrLines = file($strFile);

echo ereg_replace("Kills=","",$arrLines[6]); //will display 8343

?>

 

I can see the 2 but I am getting unrequired data from thae source also being achoed.

Can you help with this?

Firstly, in the above example, ignore the commented 8434 bit; I forgot to remove it.

 

Secondly, the source of data I am using is in PRE tags, I believe this is why the example gave above does not work. Would it be possible to cut out only information that is numeric? But, would that leave the values of the other information?

 

I cannot edit the source but would it be possible to code somethign that firstly converts the source into proper lines information with <BR />'s ect so it could be correctly read by line?

 

Thanks in advance

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.