Minase Posted March 25, 2009 Share Posted March 25, 2009 i run into this weird problem here is my code $input = file_get_contents("test.txt"); preg_match('/Battle Report (.*)Report details/s', $input, $overal); $overall = $overal[1]; preg_match('/Vitality\n(\S{1,25}) (.*) (.*)/', $overall, $attacker->Dmg); print_r($attacker->Dmg); and the test.txt Battle Report Name Hit points Vitality io 402 12.724 tu 29 0 Winner: io io captured: 46 Gold Report details if i put the above text into a string it works :| but if i read it from a file or via POST it wont any ideas? thank you Link to comment https://forums.phpfreaks.com/topic/151115-solved-string-a-b/ Share on other sites More sharing options...
lonewolf217 Posted March 25, 2009 Share Posted March 25, 2009 not entirely sure what you are trying to match and having a problem with, but I would guess that when reading from a file you have to deal with newline breaks which may screw up any matching you try to do ? Link to comment https://forums.phpfreaks.com/topic/151115-solved-string-a-b/#findComment-793830 Share on other sites More sharing options...
Minase Posted March 25, 2009 Author Share Posted March 25, 2009 baka me :| i forgot that i need to use \r\n instead of \n -.- thank you very much for remembering Link to comment https://forums.phpfreaks.com/topic/151115-solved-string-a-b/#findComment-793834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.