Mycotheologist Posted June 30, 2012 Share Posted June 30, 2012 I need to extract some data from text files, heres the line in the text file containing the value that I need: SCF Done: E(RB3LYP) = -3540.94178466 A.U. after 20 cycles the value that I need is -3540.94178466. Heres the code I am using: if (preg_match_all('/SCF Done: E\(RB3LYP\) = (.*?)A.U./msU',$file_contents,$matches)) { $content = $matches[0][0]; } echo $content; When I echo the $content variable, heres what it outputs: SCF Done: E(RB3LYP) = -3540.94178466 A.U. How can I output the value itself, without the delimiters? In other words, I need to output just the value -3540.94178466, not the crap surrounding it. Link to comment https://forums.phpfreaks.com/topic/265059-extracting-a-value-noob-question/ Share on other sites More sharing options...
requinix Posted June 30, 2012 Share Posted June 30, 2012 Take a look at what other information is available in $matches. Link to comment https://forums.phpfreaks.com/topic/265059-extracting-a-value-noob-question/#findComment-1358225 Share on other sites More sharing options...
Mycotheologist Posted June 30, 2012 Author Share Posted June 30, 2012 Ah, the answer was right under my nose the whole time. $matches[1][0] contains the value without the delimiters. Thanks a lot! Link to comment https://forums.phpfreaks.com/topic/265059-extracting-a-value-noob-question/#findComment-1358230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.