Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php regex help

Status
Not open for further replies.

leegold

Technical User
Mar 19, 2002
39
US
I'm new to PHP regex. What I am trying to match is:
Obviously it's a mysql/php field.
Then if a match I take some action.
But it's not working any help appreciated.

while ( $row = mysql_fetch_row( $result ) ) {...
....
foreach($row as $data) {
if (preg_match("/ $data)) {
$data= 'You got a match';
}
 
If that's really what you want to match, don't bother with a regex... just do
Code:
if ($data == '[URL unfurl="true"]http://library.dayton.town.net')[/URL] {
  echo 'Matched...';
}

Regular expressions are for matching patterns. So for example, if you wanted to find everything which started with http: and ended with .net you could do
Code:
$pattern = '/^http:.*\.net$/';

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top