While parsing a CSV file(I have used a Class found on Google), I ran into a problem. Here is an example of an array made from a .csv file(print_r):
Array
(
[0] => Array
(
[Site] => ViralNova
[Impressions] => 104719
[CTR] => 0.30%
[Clicks] => 311
[Average CPC] => $ 0.400
[CPM] => $ 1.19
[Conversion Rate] => 1.29%
[Actions] => 4
[CPA] => $ 31.100
[Spent] => $ 124.40
)
[1] => Array
(
[Site] => TMZ - Desktop
[Impressions] => 103276
[CTR] => 0.29%
[Clicks] => 295
[Average CPC] => $ 0.400
[CPM] => $ 1.14
[Conversion Rate] => 0.68%
[Actions] => 2
[CPA] => $ 59.000
[Spent] => $ 118.00
)
)
The Problem is that I cannot use the "Site" index. Whenever I try to, I get this notice:
<b>Notice</b>: Undefined index: Site in <b>C:\xampp\htdocs\panel\update\assets\php\core\core-ajax.php</b> on line <b>104</b><br />
Line 104 being:
print $data[0]['Site'];
Also,
print $data[0]['Impressions'];
or
print_r($data[0]);
works without any problem and I get the correct value/array.
Any ideas?
Thanks!!
var_dump($data)and look at the output in the source code! <- Show that' Site'not'Site'. Doecho $data[0][' Site']and see if it works.[' Site']instead of['Site']. Tested it on my local and worked fine.