I am currently having an issue with random strings in either variables or array values being lower cased periodically.
Here is an example of what I'm seeing with an array:
$modules = array("Dashboard", "Calendar", "Maintenance", "Service Orders", "Quotes", "Contacts");
var_dump($modules);
Output:
array(6) { [0]=> string(9) "Dashboard" [1]=> string(8) "Calendar" [2]=> string(11) "maintenance" [3]=> string(14) "Service Orders" [4]=> string(6) "Quotes" [5]=> string(8) "Contacts" }
I am doing an in_array()
condition but it is not finding "Maintenance" due to it being "maintenance".
EDIT
Here is an example of what happens with passing a string through a method that tries to get the index in the $_REQUEST
var:
class RequestHandle {
/**
* Get the parameter index of the request var
* @param $index
* @return string|array
*/
public static function getParameter($index){
$value = "";
$data = $_REQUEST;
if(isset($data[$index]) && !is_array($data[$index])) {
$value = trim($data[$index]);
} else if(isset($data[$index]) && is_array($data[$index])) {
foreach($data[$index] as $key => $value){
$data[$index][$key] = $value;
}
$value = $data[$index];
}
return $value;
}
}
$costs = RequestHandle::getParameter("SubLaborCosts");
Output:
string(0) ""
The Request var is set and with data. When I do a print of $index
in the getParameter
method it will display "sublaborcosts", sometimes, and not find the index since "SubLaborCosts" =/= "sublaborcosts". In order for me to correctly grab data without missing anything, I had to modify the method to include:
$data = array_change_key_case($_REQUEST);
$index = strtolower($index);
And this is even now and then, 80% of the time it is correct in showing exactly what I have set.
I've never seen this before and here is a list of items that are new to this happening that I think might have an effect... just can't find the solution.
- UTF-8 charset
- PHP 5.5
- intl extension
- Windows Server 2012
Any help or ideas would be greatly appreciated!