Page 1 of 1

preg_match I think...

Posted: Sat Aug 14, 2004 1:41 pm
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 !

Posted: Sat Aug 14, 2004 1:55 pm
by feyd

Code: Select all

<?php

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

?>
:?::?:

...

Posted: Sat Aug 14, 2004 2:09 pm
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 !

Posted: Sat Aug 14, 2004 10:56 pm
by feyd
you need to pass it the string you want to test against.

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