例如,如果我有一個陣列:
$indicators = ['open','high','low','close'];
是否可以使用這些函式引數而不將它們硬編碼到函式中?
customFunction($open,$high,$low,$close);
uj5u.com熱心網友回復:
您可能正在尋找擴展語法運算子,即
customFunction(...$indicators);
uj5u.com熱心網友回復:
如果您不能使用擴展運算子,您還可以使用call_user_func_array:
call_user_func_array('customFunction', $indicators);
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/346080.html
標籤:php
