如何使用这个PHP功能?

时间:2012-02-20 00:46:14

标签: php function

假设我有这个功能,但我不知道怎么称呼它......

echo getYoutubeSearchVideosFeeds($variables);

用什么我应该替换$变量来调用$ q,$ orderby,$ startIndex等等?

function getYoutubeSearchVideosFeeds($criteria) {
    $url = 'http://gdata.youtube.com/feeds/api/videos?';
    $q = urlencode($criteria['q']);
    $orderby = $criteria['orderby']; // relevance, published, viewCount, rating
    $startIndex = $criteria['start-index'];
    $maxResults = $criteria['max-results'];
    $author = $criteria['author'];
    $format = $criteria['format'];
    $lr = $criteria['lr']; // fr, en
    $safeSearch = $criteria['safeSearch']; //none, moderate, strict

  // more code 
}

3 个答案:

答案 0 :(得分:0)

只需传递一个关联数组,其中包含函数中列出的值:

getYoutubeSearchVideosFeeds(array('q' => '...', 'orderby' => '...', ...));

答案 1 :(得分:0)

传递一个数组,该数组填充了函数所需的每个键的值:

 getYoutubeSearchVideosFeeds(array('q' => '...',  'orderby' => '...'));

答案 2 :(得分:0)

getYoutubeSearchVideosFeeds(

array(

"q"=>"CriteriaValuesHere..GetItFromGDataHelp",
"start-index" => "Other Values"
.
.
.        
)


);