I have to compare two strings for case insensitive equality which one is faster strcasecmp() or equal to operator
$str1='Hello';
$str2='hello';
//first approach
if($str1 != strotolower($str2))
//do some stuff here
//second approach
if(strcasecmp($str1,$str2) !=0)
//do some stuff here)
which approach is better/faster?
Both approaches are o(n) in speed however usign strtolower allocates a new string to hold the result which in turn increases memory pressure and reduces performance