I'm trying to figure out why my code is not returning the key associated with the value of an array. This program should compare the first letter of an item with an array in which the letters A-M are associated with a key of "1" and letters N-Z are associated with a key of "2" to indicate the aisle they would be located on. The most frequent error I'm getting is that the second parameter of the array_search is not an array, but I thought array_combine combined two arrays into a new array, thus ($aisles, $letters) should produce 1=>A, 1=>B and so on. The webpage form I'm using this on can be found at http://achamlin.gwiddle.co.uk/web182/Project3/HamlinProject3.php I keep getting the same output: "Banana is located on Aisle ." with no actual Aisle listed. Thanks for any help.
//create function to compare first letter of item to the aisle arrays
function checkAisle($term) {
$item= "banana";
$letters = array("A", "B", "C", "D", "E", "F", "G","H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T","U", "V", "W", "X", "Y", "Z");
$aisles = array("1", "1", "1", "1", "1", "1", "1","1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2","2", "2", "2", "2", "2", "2");$itemUC = UCfirst($item);
$guide = array_combine($aisles, $letters);
$itemUC = UCfirst($item);
$firstChar = $itemUC[0];
$location = array_search($firstChar, $guide);
echo "$itemUC is located on Aisle $location.";
}
//run function
checkAisle("banana");