ballouta Posted June 16, 2008 Share Posted June 16, 2008 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 Link to comment https://forums.phpfreaks.com/topic/110396-solved-searhing-for-characters-in-a-file-name/ Share on other sites More sharing options...
thebadbad Posted June 16, 2008 Share Posted June 16, 2008 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' } } ?> Link to comment https://forums.phpfreaks.com/topic/110396-solved-searhing-for-characters-in-a-file-name/#findComment-566364 Share on other sites More sharing options...
ballouta Posted June 16, 2008 Author Share Posted June 16, 2008 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 Link to comment https://forums.phpfreaks.com/topic/110396-solved-searhing-for-characters-in-a-file-name/#findComment-566373 Share on other sites More sharing options...
thebadbad Posted June 16, 2008 Share Posted June 16, 2008 Use mysql_num_rows(): <?php $query = "SELECT * FROM `uploaded` WHERE `sentfile` = '$file' AND `received` = 'N' "; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { //found rows } else { //no rows } ?> Link to comment https://forums.phpfreaks.com/topic/110396-solved-searhing-for-characters-in-a-file-name/#findComment-566392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.