I'm trying to fetch the version number of PHP from a text stream. This is just a test for a structure I plan to use to fetch other data. The fact that I am fetching the PHP version out of a text file isn't the end goal but the way I'm trying to do it is. I'm using regex. My code snippet below only displays "PHP Version:" and not "PHP Version: 5.2.6".
My preg_match() function is not working correctly to pull the '5.2.6' value into my $out3 array. I would like to use this structure to also fetch non-digit strings as well so that's why I used .* in the capture section. But even that is not working!
PHP Code:
$view = "PHP version 5.2.6"; preg_match('/PHP version(.*)/smiU', $view, $out3); echo $out3[1].'<br>'; $phpVer = trim($out3[1]); echo 'PHP Version: '.$phpVer;
and to also work with
PHP Code:
$view = "OS Linux.CURRENT(Linux)"; preg_match('/OS(.*)/smiU', $view, $out3); echo $out3[1].'<br>'; $phpVer = trim($out3[1]); echo 'OS: '.$phpVer;
__________________
RalphF
Business Text Messaging Services
Please login or register to view this content. Registration is FREE
Last edited by rfresh; 12-06-2008 at 01:24 PM..
|