Example 1 — Parse a Simple Line
Turn a comma-separated line into an array.
<?php
$row = str_getcsv("apple,banana,cherry");
print_r($row); How It Works
- Pass a CSV line. Values are separated by commas.
- Default separator. A comma is used when you pass nothing else.
- Get an array. Each field is one element.
- Print it.
print_r()shows the structure.

