【发布时间】:2015-09-24 14:53:04
【问题描述】:
我正在尝试从以下 json 响应中获取特定文件。我正在使用 Amazon SNS,我想获取输出键变量(“key”:“4177/media/test1.mp4”)并且只返回 4177。所以基本上我想获得第一个 / 输出之前的任何内容关键变量。我该怎么办?提前感谢您的时间。
{
"state" : "COMPLETED",
"version" : "2012-09-25",
"jobId" : "1443105433825-ax3k5c",
"pipelineId" : "1442869133716-ncyq63",
"input" : {
"key" : "sample.mp4",
"frameRate" : "auto",
"resolution" : "auto",
"aspectRatio" : "auto",
"interlaced" : "auto",
"container" : "auto"
},
"outputs" : [ {
"id" : "1",
"presetId" : "1443042941302-mvvgq6",
"key" : "4177/media/test1.mp4",
"thumbnailPattern" : "4177/thumbs/test1-{count}",
"rotate" : "auto",
"status" : "Complete",
"statusDetail" : "The input file for this job contains 6 audio channels and the preset is configured for 2 audio channels. Amazon Elastic Transcoder audio-channel mapping may not result in the desired audio.",
"duration" : 6,
"width" : 1280,
"height" : 720
} ]
}
我正在通过 $msgs = json_decode(file_get_contents('php://input'), true); 抓取 json;
【问题讨论】:
-
$msgs['outputs'][0]['key']。$msgs['outputs']是一个对象数组。如果您期望不止一个对象,则可以循环遍历它。 -
这不起作用,但是,感谢您的帮助。