我目前正在使用drupal和Flowplayer API。
在Javascript中,一切对我来说都很容易,但当涉及到PHP时,我的noob知识还不够。
我需要一个像这样的javascript结构来让流播放器插件工作:
"ads" : {
"schedule" : [ {
"position" : "pre-roll",
"server" : {
"type" : "direct",
"timeoutInSeconds" : 5,
"tag" : "http%3Asomething",
}
} ]
}
但是我的php API
'ads'=> array(
'scheudle'=>array(
'position'=>'pre-roll',
'server'=> array(
'type'=>'direct',
"timeoutInSeconds"=>5,
"tag"=>"httpsomething",
)
)
)
我得到的JavaScript是这样的:
"ads":{
"scheudle":{ /*HERE NEEDS TO BE A WRAPPING [] ARRAY LIKE ABOVE */
"position":"pre-roll",
"server":{
"type":"direct",
"timeoutInSeconds":5,
"tag":"http%3something"
}
}
},
如何使我的PHP输出具有正确的js结构?
使用此:
'ads'=> array(
'scheudle'=>array(array(
'position'=>'pre-roll',
'server'=> array(
'type'=>'direct',
"timeoutInSeconds"=>5,
"tag"=>"httpsomething",
)
))
)