preg_match I think...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

preg_match I think...

Post by Calimero »

Hi,

I haven't yet used preg_match - succesfully,

I tried, but can't figure it out.


I need this

a result is returned from mysql,
I need php to check in that result (sometext_somefile.ext) if this string exists in it '.___' - to check if this text/file has an extension or not. (I cant do it in mysql because of the code it self, I know about like and __)


please if you have a code, and it urgent, i need this or I will manualy check many records and corresponding files


Thanks Ahead !
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<?php

$found = preg_match('#\.___#', file_get_contents($filename));

?>
:?::?:
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

Thanks, I'll test it as soon as I write a little even more ugent code :)

If I let out file_get_contents

$found = preg_match('#\.___#, )

like this will it work, and further more because I need this matching at the end of the text-srting can I leave out the last #

$found = preg_match('#\.___, )

Thanks Ahead !
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you need to pass it the string you want to test against.

removing the last # will result in a regex engine error.
Post Reply