kelphyr Posted February 18, 2007 Share Posted February 18, 2007 How to read between "," like "john,george,bob"? How to change lines? like how to detect an end of line? How to check a like for like "//"... How to target a specific line..? If you know those pelase reply Link to comment https://forums.phpfreaks.com/topic/39041-file-reading-questions/ Share on other sites More sharing options...
printf Posted February 18, 2007 Share Posted February 18, 2007 Can you give example of a few lines from your file, including the line you want to edit! printf Link to comment https://forums.phpfreaks.com/topic/39041-file-reading-questions/#findComment-188046 Share on other sites More sharing options...
kelphyr Posted February 18, 2007 Author Share Posted February 18, 2007 http://gamingtwilight.com/rodb/item_db.txt This is the file I need to play with... but like I said, there's no way I can do anything without detecting an end of line. Because I wana like do: Read Line Process... Then Read the second line... and just keep going. I need to infuse it into a mysql database but there's no way to do taht without being able to read the fiel properly and no one has been able to help me so far. It's as if no one has file manipulating experience. Id do something like this: $line = 0 While(not end of FILE){ While(not end of LINE){ read the line process the line(cant do that cuz i dont know how to separate my stuff with " , " as " this, this, this " } $line = $line + 1 } .... So Im basicly stuck to this part... how do i detect an end of line and how can i separate my content with ","... Link to comment https://forums.phpfreaks.com/topic/39041-file-reading-questions/#findComment-188056 Share on other sites More sharing options...
superuser2 Posted February 18, 2007 Share Posted February 18, 2007 #1: explode - http://php.net/explode - Puts them into an array #2: To detect the end of a line - str_pos for \n (\n means return) #3: Once again, check out str_pos and regular expressions (preg_match) #4: I don't know what you mean by this. Like by line number? Link to comment https://forums.phpfreaks.com/topic/39041-file-reading-questions/#findComment-188062 Share on other sites More sharing options...
kelphyr Posted February 18, 2007 Author Share Posted February 18, 2007 yes by line numbers basicly i just wana read line by line and if it does not start by //(which is a comment) then process it and add it to the mysql database. But I also need a way to read "john,bob,george" inbetween "," and put those into variables and then send it to teh db. Link to comment https://forums.phpfreaks.com/topic/39041-file-reading-questions/#findComment-188096 Share on other sites More sharing options...
kelphyr Posted February 18, 2007 Author Share Posted February 18, 2007 ok now im able to read 1 line after the other... now how can I know if the line starts with "//"? Link to comment https://forums.phpfreaks.com/topic/39041-file-reading-questions/#findComment-188129 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.