Jump to content

[SOLVED] Searhing for Characters in a File Name


ballouta

Recommended Posts

Hello

I have a fucntion that loops a directory and output files names.

this directory contains three files:

 

1) 12345.ask ( i am able to process it without problems)

2) 12345.rpl  ( I am able to process this file if I didn't have the third file, but i always have a third file)!

3) 12345nss.rpl (Here is the problem)

 

I want to check the two .rpl files which one contains the letters nss

please help

When you have access to the filename, you can check if it contains 'nss' this way:

 

<?php
if (strpos($filename, 'nss') !== false) {
//$filename contains 'nss'
}
?>

 

If you only want to check the .rpl files, simply add another if statement:

 

<?php
if (end(explode('.', $filename)) == 'rpl') {
if (strpos($filename, 'nss') !== false) {
	//$filename contains 'nss'
}
}
?>

Thanks It is ! :)

 

Please I have another question, I have this query:

 

$query = "SELECT * FROM `uploaded` WHERE `sentfile` = '$file' AND `received` = 'N' ";

 

I need to check if the query has returned values or not, I mean what if this qurey didn't find any info in the table, how should I know?

 

e.g.:

 

If the query has returned value(s), I will ask him to update the table other wise

it should prompt me.

 

 

thanks again

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.