hello guys i have search a lot, and iam trying to make that working. The following script searches recursive for the files into all folders.
if(isset($_POST['cmdsearch']))
{
$search = $_POST['search'];
if (@get_magic_quotes_gpc())
{
$search = stripslashes($search);
}
$it = new RecursiveDirectoryIterator("jpg");
foreach(new RecursiveIteratorIterator($it) as $file)
{
if (false !== stripos($file, $search))
{
echo "<a style='padding:10px 10px 5px 5px; text-decoration:none; line-height:15px;' class='smamal' target='_blank' href='http://www.domain.com/files/";
echo $file;
echo "'>";
echo "www.domain.gr/files/";
echo $file;
echo "</a>";
echo "<br />";
}
}
}
else
{
echo "<p></p>";
}
WHAT I WANT TO ADD:
i am trying to add into the code something like this
/\b([a-z]+[A-Z]+[a-zA-Z]*|[A-Z]+[a-z]+[a-zA-Z]*)\b/
thanks for your time.
Why don't convert search and filename to lowercase. This way you will get case-insensitive matches. Another option is to set the flag i
for case-insensitive matches in regular expressions. For matching the first four characters use substr
on both strings before comparing them.
If you really search large datasets think about using something like elastic search. This will even provide you fuzzy search (e.g. heaflines will also return results for headlines).
i think this is what i need to embed in my code. a function to convert all accent characters and then make them lowercase. both in FILENAME AND SEARCH but i have no idea how to embed it. please any help?
function normaliza ($string){
$a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ
ßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ';
$b = 'aaaaaaaceeeeiiiidnoooooouuuuy
bsaaaaaaaceeeeiiiidnoooooouuuyybyRr';
$string = utf8_decode($string);
$string = strtr($string, utf8_decode($a), $b);
$string = strtolower($string);
return utf8_encode($string);
}