How can PHP code be optimized to handle user input in different formats, such as lowercase and uppercase?

When handling user input in different formats, such as lowercase and uppercase, it is important to normalize the input to a consistent format for processing. This can be achieved by converting all user input to a specific case, such as lowercase or uppercase, before performing any comparisons or operations on it. This ensures that the input is consistent and eliminates potential issues related to case sensitivity.

// Normalize user input to lowercase
$userInput = strtolower($_POST['user_input']);

// Use $userInput for further processing