PHP 8.4.24 Released!

Voting

: max(seven, four)?
(Example: nine)

The Note You're Voting On

nicolasbonnici at gmail dot com
1 year ago
Better way to get an associative key value array output.

$output = [];
$lines = array_values(explode(PHP_EOL, $your_csv_string));
$headers = str_getcsv(array_shift($lines));
    foreach ($lines as $line) {
        $parsedLine = str_getcsv($line);
        if (count($headers) !== count($parsedLine)) {
            continue;
        }
        $output[] = array_combine($headers, $parsedLine);
}
var_dump($output);

<< Back to user notes page

To Top