I have written and test my php code (not WordPress) it works well. But it doesn't work in WordPress. here's my snippet code (got error result):
function totalTrackLenght($tracklenght){
global $row, $data, $tracklenght;
foreach ($data->results as $row) {
if(!empty($row->trackTimeMillis)){
$tracklenght += $row->trackTimeMillis;
}
}
return $tracklenght;
}
php file to display the result:
<li class="total-tr-lenght"><?php nextFunction(); ?></li>
I change foreach ($data->results as $row)
to foreach ((array)$data->results as $row)
is getting no result.
The JSON data obtained from https://itunes.apple.com/us/lookup?id=1434446667&entity=song