Skip to content

Instantly share code, notes, and snippets.

@Tusko
Last active December 2, 2017 01:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tusko/893b6c8822c74d44c4002ca37bb31b69 to your computer and use it in GitHub Desktop.
Save Tusko/893b6c8822c74d44c4002ca37bb31b69 to your computer and use it in GitHub Desktop.
Parse CSV by line (acf repeater)
<?php
$file = file_get_contents('/wp-content/themes/themename/analyzers.csv');
$lines = explode(PHP_EOL, $file);
$array = array();
foreach ($lines as $line) {
$l = str_getcsv($line);
$array[] = array(
'brand' => $l[1],
'model' => $l[0],
);
}
update_field('analyzers_list', $array, $post->ID);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment