Is there a way to get PHP to search and come back results no matter the difference of upper or lowercase letters. My current code searches and only comes back with exact results of upper and lower case. So i made it all lowercase, but i want the results to have the correct uppercase letters for names.
It's searching via LDAP. The values are information from Active Directory, the search is searching the names of people, and giving the results such as Phone Number etc of that person
Here is my code:
// Address Book Search
$search .= "<div class='border'>\n";
$search .= "<h1>Search for Staff</h1>";
$search .= '<form class="search-form-wrapper" method="GET">
<input type="text" name="q" id="search" placeholder="Search for Staff..." required>
<input type="submit" value="go" id="submit">
</form><br><br>';
if (count($staff)) {
if (isset($_GET['q'])) {
$query = strip_tags($_GET['q']);
$query = str_replace('%27', "'", $query);
$query = strtolower($query);
$search .= "<table class='address_book'><tr><th>Name</th><th>Title</th><th>Phone</th><th>Mobile</th><th>Email</th><th>Dept</th></tr>\n";
foreach ($staff as $key => $details) {
$details['displayname'] = strtolower($details['displayname']);
if(substr_count($details['displayname'], $query)){
$search .= "<tr><td>{$details['displayname']}</td>\n";
$search .= "<td>{$details['title']}</td>\n";
$search .= "<td>{$details['telephonenumber']}</td>\n";
$search .= "<td>{$details['mobile']}</td>\n";
$search .= "<td><a href='mailto:{$details['mail']}'>{$details['mail']}</a></td>\n";
$search .= "<td>{$details['department']}</td>\n";
$search .= "</tr>\n";
}
}
$search .= "</table>\n";
}
}
$search .= "</div><br>";