I have a csv with two rows.
if (($handle = fopen("twoRows.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
print_r($data);
This returns two arrays with a line break at the end of the first array.
If I want to access the first column, I do
echo $data[0];
And get
value1
value2
Yet, if I do something like:
$data[0] = $post_ID;
echo 'Post ID = ' . $post_ID . '<br />';
I get zero output on $post_ID
Post ID =
Post ID =
How can I perform a function on each first column value?
where is $post_ID
declared?
Don't you mean to do
$post_ID = $data[0];
echo 'Post ID = ' . $post_ID . '<br />';