Hello there, I have a class (didn't want to paste in the whole class, so I just put in the relevant part) it works fine except for one problem. The function that I have here has a minor problem, it doesn't parse out all the data correctly, the Current file doesn't come up all the time. It is becoming a problem now that it is manifesting itself. I had this script running a lot but I had to remove it from the production server because of the problems that it caused. Could someone please shed some light on this for me?
<?php Class parseme(){ Parseme($file,$debug){ $this->debug = debug; $this->fp = Fopen($file,"r"); } function getinformation($string){ if($this->debug){ print "entering while loop!\n"; } while (trim($string) != "+OK"){ if($string == "+OK"){ if($this->debug){ print trim("String is '$string'"); } break; } $string = fgets($this->fp,200); if($this->debug){ print "String is *". trim($string)."*\n"; print "substr(\$string,0,1) = *". substr($string,0,1) ."*\n"; } if($i == 4){ }else{ if(substr($string,0,1) == "M"){ $this->status = trim(substr($string,10)); if($this->debug){ print trim("Got Status of *{$this->status}*") ."\n"; } } if(trim(substr($string,0,1)) == "C"){ // <-- This line is where I have problems if($this->debug){ print "Trackname detected....\n"; } $this->TrackName = trim(substr($string,strpos($string,".")+1)); } if(substr($string,0,1) == "S"){ // test of explode and such// list($this->samplerate,$this->bitrate,$this->channels) =explode(",",$string); list($junk, $this->samplerate) = explode(": ",$this->samplerate); list($junk, $this->bitrate) = explode(": ",$this->bitrate); list($junk, $this->channels) = explode(": ",$this->channels); if($this->debug){ print "Samplerate : $this->samplerate\n"; print "Bitrate : $this->bitrate\n"; print "Channels : $this->channels\n"; } } } $i++; } } $some = new parseme("status.txt",true); $some->getinformation(); ?> // status.txt contents System status: =============================================== Shuffle: Disabled Repeat: Enabled Music is: PLAYING Current song: 01. DJ Encore - I See Right Through To You Samplerate: 44kHz, Bitrate: 160kbps, Channels: 2 +OK // end file contents // output of the script running entering while loop! String is *Shuffle: Disabled* substr($string,0,1) = *S* Samplerate : Disabled Bitrate : Channels : String is *Repeat: Enabled* substr($string,0,1) = *R* String is *Music is: PAUSED* substr($string,0,1) = *M* Got Status of *PAUSED* String is ** substr($string,0,1) = * * String is *Current song: 01. DJ Encore - I See Right Through To You* substr($string,0,1) = *C* String is *Samplerate: 44kHz, Bitrate: 160kbps, Channels: 2* substr($string,0,1) = *S* Samplerate : 44kHz Bitrate : 160kbps Channels : 2 String is ** substr($string,0,1) = * * String is *+OK* substr($string,0,1) = *+* If I wasn't good at explaining myself please tell me. Thank You, Mike [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php