2010-02-12 64 views
2

這裏的功能是代碼:發送陣列在PHP

function dosomething() 
{ 
    ... do something with the array... like print value ! 
} 

$ar = array(1,2,3); 
dosomething ($ar); 

這段代碼做工精細...

我嘗試做的是直接傳遞數組功能 我有嘗試這個,不工作...幫助!

dosomething ([12,32,56]); 
dosomething ({12,45,87}); 
dosomething ("[98,74,52]"); 

回答

7
dosomething(array(12,32,56)); 
1

首先你必須指定該函數的參數:

function dosomething($array) { var_dump($array); } 

然後,你必須傳遞數組和定義它就像你在你的代碼沒有,但直接在函數:

dosomething(array(1,2,3));