PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
JKM
Forum Contributor
Posts: 221 Joined: Tue Jun 17, 2008 8:12 pm
Post
by JKM » Sat Jun 19, 2010 2:09 pm
Hi there,
Code: Select all
$array = array('jpg', 'gif');
$extension = explode('.', $_FILES['file']['name']);
$extension = $extension[count($extension)-1];
$continue = in_array($array, $extension) ? true : false;Is it possible to make in_array() case insensitive, or is there another function I can use?
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sat Jun 19, 2010 2:34 pm
in_array doesn't do string searching. It doesn't know what case-insensitivity means.
If there isn't a built-in function for this (I don't remember one), try your hand at
a loop and
strcasecmp .
JKM
Forum Contributor
Posts: 221 Joined: Tue Jun 17, 2008 8:12 pm
Post
by JKM » Sat Jun 19, 2010 4:00 pm
nevermind:
Code: Select all
$continue = in_array(strtolower($array), $extension) ? true : false;