What potential pitfalls can arise when splitting a CSV column with nested categories in PHP?

When splitting a CSV column with nested categories in PHP, potential pitfalls can arise if the nested categories contain commas or other delimiters used in CSV. To solve this issue, you can use PHP's str_getcsv() function to properly parse the CSV data while considering the nested categories.

// Sample CSV data with nested categories
$csvData = 'Category 1,Subcategory 1,Subcategory 2,"Subcategory, 3",Category 2,Subcategory 1';

// Split the CSV data while handling nested categories
$rows = str_getcsv($csvData);

// Output the parsed data
print_r($rows);