2010-11-28 242 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; 
} 

回答

相關問題