我有一个像这样的php数组:
array(3) {
[1]=>
array(1) {
[12302]=>
array(3) {
[8766]=>
array(6) {
["thumbnail"]=>
string(...) "..."
["mainthumbnail"]=>
string(...) "..."
["mp4url"]=>
string(...) "..."
["webmurl"]=>
string(...) "..."
["clipid"]=>
string(4) "8766"
["title"]=>
string(0) ""
}
[7346]=>
array(6) {
["thumbnail"]=>
string(...) "..."
["mainthumbnail"]=>
string(...) "..."
["mp4url"]=>
string(...) "..."
["webmurl"]=>
string(...) "..."
["clipid"]=>
string(4) "7346"
["title"]=>
string(0) ""
}
[2013]=>
array(6) {
["thumbnail"]=>
string(...) "..."
["mainthumbnail"]=>
string(...) "..."
["mp4url"]=>
string(...) "..."
["webmurl"]=>
string(...) "..."
["clipid"]=>
string(4) "2013"
["title"]=>
string(0) ""
}
}
}
[2]=>
array(1) {
[9803]=>
array(1) {
[2614]=>
array(6) {
["thumbnail"]=>
string(...) "..."
["mainthumbnail"]=>
string(...) "..."
["mp4url"]=>
string(...) "..."
["webmurl"]=>
string(...) "..."
["clipid"]=>
string(4) "2614"
["title"]=>
string(5) "Titel"
}
}
}
[3]=>
array(1) {
[9041]=>
array(1) {
[8766]=>
array(6) {
["thumbnail"]=>
string(...) "..."
["mainthumbnail"]=>
string(...) "..."
["mp4url"]=>
string(...) "..."
["webmurl"]=>
string(...) "..."
["clipid"]=>
string(4) "8766"
["title"]=>
string(0) ""
}
}
}
}
我将该数组传递给javascript,如下所示:
var pdf_videos = <?php echo json_encode($pdf_videos); ?>;
然后我使用这个javascript函数来接收ID:
if(typeof pdf_videos.map == 'function'){
var topkeys = pdf_videos.map(function (k) {
return Object.keys(k);
});
}
但它返回undefined。为什么不起作用?此代码与PDF文件有关。每个PDF都可以有一个或多个视频文件。如果每个PDF文件都至少有一个视频,那就可以了。