Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-06-2008, 01:22 PM preg_match Help
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
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..
rfresh is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-06-2008, 06:50 PM Re: preg_match Help
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Why do you use the U modifier?
Do you have any particular reason for it? Because I think it will work if you remove it.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 12-07-2008, 01:13 AM Re: preg_match Help
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
The U (Unicode) was a left over I was trying. I removed it and it didn't make any difference. I'll keep working on this. Thanks...
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
Old 12-07-2008, 05:28 AM Re: preg_match Help
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
In PHP, U is not the Unicode modifier. http://php.net/manual/en/reference.p....modifiers.php

My suggestion for a new pattern:
PHP Code:
'/PHP version(\s*)(.*)/i' 
Then, hopefully, $out3[2]='5.2.6'
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to preg_match Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32580 seconds with 12 queries