---
title: "Sök funktion"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/96498-sök-funktion"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "icarus"
published: "2004-02-03T17:00:57.000Z"
updated: "2004-02-03T17:00:57.000Z"
replies: 0
views: 294
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/96498-sök-funktion"
---

# Sök funktion

## #1 — icarus, 2004-02-03T17:00Z

Hej Jag är helt nybörjare på php men har fått hjälp
med en liten sök funktion till mina mp3:or.

Jag har fixat en mp3.txt fil med all mina mp3:or med hjälp av

find /home/MP3\* \| grep -i .mp3 \> /www/htdocs/mp3.txt 

och sen så kommer min sök funktion i php här:

\<html\>
\<title\>File Search\</title\>
\<body\>
\<form method="post" action="search.php" class=field\>
MP3:

\<input type="text" name="search" size="30"\> \<input value="search" type="submit" name="submit"\>\<br\>&nbsp;\<br\>
\</form\>

\</form\>

\<?php
$file = "http://192.168.0.1/mp3.txt";
$search = addslashes(trim($search));
$searcha = explode(" ", $search);

$fd=fopen("$file","r");
$i = 0;
while ($line=fgets($fd,1000))
{
    $search_array\[$i\] = $line;
    $i++;
}
fclose ($fd);

if ($search)
{
        reset($search_array);
        while (list($key, $val) = each($search_array))
        {       $i = 0;
                $notcorrect = FALSE;
                reset ($searcha);
                while (list($key1,$val1) = each($searcha))
                {
//                      echo $searcha\[$i\];
                        if (!stristr($val, $searcha\[$i\]))
                                $notcorrect = TRUE;
                        $i++;
                }
//              echo $notcorrect;
                if (!$notcorrect)
                        echo("\<font size=\\"2\\"\>" . $val . "\</font\>\<br\>");
        }

}
?\>
\</body\>
\</html\>

Problemet är att den inte funkar ser du något fel ?
Han som gjorde detta e bortrest och skulle gärna vilja ha detta fungerande så fort som möjligt.

Tack på förhand.

Permalänk: https://www.webforum.nu/p/96498

---

Tråden på webben: https://www.webforum.nu/amne/php/96498-sök-funktion
