Array case sensitive?

Are arrays case sensitive ?

Yes, all variable names in php are case sensitive.

1 Like

Looks like you edited out the code that puts the question in context.
Although they are case sensitive, you can use functions on them which are case insensitive.
You could make the array all lowercase, then use strtolower() on any variable you want to test against it. Eg.

$myArray = array('chicken', 'dog', 'cat', 'goat');
$thisVar = "Dog" ;
if(!in_array(strtolower($thisVar), $myArray) { echo "Not Found!"; }

Yes, (or all uppercase - as long as everything gets “case standardized”)

It doesn’t help that the code has lowercase (var name typo?)

$expensions= array("jpeg","jpg","png");

but the message has uppercase

extension not allowed, please choose a JPEG or PNG file.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.