Search a list of names with student number with only a part of the name as input
<p>I am making a webpage that takes in either a student number or a part of the name of the student then searches a list of students then returns the student number and the whole name. I'm already done with when the user inputs a student number. <em>My only problem now is when the user inputs a name.</em> I was thinking of using <code>strpos()</code> but I don't know what I should do next.</p>

<p>Here's what I got so far:</p>

<pre><code>function search_name_list($file, $info)
{
    // get name list array
    $students = get_name_list($file)['students'];
    if (!$students)
    {
        return false;
    }

    // the user searched for the student number
    if (ctype_digit($info))
    {
        // return the name corresponding to the student number if found
        if (array_search($info, $students['snum']))
        {
            return $students['name'][$info];
        }
    }

    // the user searched for the name
    else
    {
        // convert array into string
        $content = implode('|', $students);

        // TODO...
    }

    return false;
}
</code></pre>

<p>I hope the comments in the code is clear enough to help you guys understand the problem. Also if you have suggestions on making the function better overall then you can say it too.</p>

<p>EDIT: I think I need an example.</p>

<p>For example: The array contains ["20111122953", "Acosta, Arbyn", "20111112345", "Mayer, Patrick"]. But the user only inputted "Arbyn" or "Acosta" then I need to search the array with only that sub string in my possession. Then return the name and the student number corresponding to my name.</p>
