What are common pitfalls when using regular expressions in PHP, specifically for parsing strings into arrays?

Common pitfalls when using regular expressions in PHP for parsing strings into arrays include not properly escaping special characters, not handling optional elements correctly, and not considering the possibility of multiple matches in the input string. To solve these issues, make sure to escape special characters, use proper quantifiers for optional elements, and use functions like preg_match_all() to handle multiple matches.

// Example code snippet to parse a string into an array using regular expressions
$input = "apple, banana, cherry";
$pattern = '/\s*,\s*/';
$fruits = preg_split($pattern, $input);

print_r($fruits);