What are some common pitfalls to avoid when working with arrays and strings in PHP?

One common pitfall when working with arrays and strings in PHP is not properly sanitizing user input, which can lead to security vulnerabilities such as SQL injection or cross-site scripting attacks. To avoid this, always use functions like `htmlspecialchars()` or `mysqli_real_escape_string()` to sanitize user input before using it in queries or outputting it to the browser.

// Example of sanitizing user input using htmlspecialchars()
$user_input = "<script>alert('XSS attack');</script>";
$sanitized_input = htmlspecialchars($user_input);
echo $sanitized_input;