Undefined Index for Valid key from array in PHP -
while parsing csv file(i have used class found on google), ran problem. here example of array made .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 cannot use "site" index. whenever try to, 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 problem , correct value/array.
any ideas?
thanks!!
acc. me code running fine. problem occur when in loop in point index missing.
to resolve issue..
use this..
<?php if($data[0]['site']){ print $data[0]['site']; } // if($data[0]['impressions']){ print print $data[0]['impressions']; } ?>
Comments
Post a Comment