PHP Function Argument to an array

后端 未结 4 484
时光说笑
时光说笑 2021-01-28 00:59

Can you do something crazy like this

function cool_function($pizza, $ice_cream) { 

   make the arguments in the array into an array 
   return $array_of_parama         


        
4条回答
  •  情书的邮戳
    2021-01-28 01:26

    If I got you right, you so it like this:

    function cool_function($pizza, $ice_cream) {
       return array($pizza, $ice_cream);
    }
    

    but you could simply do that:

    $new_var = array($pizza, $ice_cream);
    

提交回复
热议问题