2010-11-28 241 views
0

如何将各种类型的参数数组转换为函数中的实际参数?

$params = array('the title2', 'the footer2', 10); 
displayTest(implode(',', $params)); //how??? 
displayTest(convert_to_parameters($params)); //how??? 

function displayTest($title, $footer, $numberOfItems = 0) { 
    $r = ''; 
    $r .= '<div>'.$title.'</div>'; 
    for($index = 0; $index < $numberOfItems; $index++) { 
     $r .= '<div>the text</div>'; 
    } 
    $r .= '<div>'.$footer.'</div>'; 
    return $r; 
} 

回答

相关问题