codeigniter sanitize input field

// Load the CodeIgniter Input library

// Get user input data from a form field named 'user_input'
$userInput = $this->input->post('user_input', TRUE);

// Sanitize the input using CodeIgniter's built-in xss_clean function
$cleanedInput = $this->input->xss_clean($userInput);

// Optionally, you can further sanitize the input using additional filters
$filteredInput = filter_var($cleanedInput, FILTER_SANITIZE_STRING);

// Use the sanitized input as needed in your application
// For example, you can save it to a database or display it in a view
echo $filteredInput;