What is the best practice when creating functions / methods in PHP, do you use arrays or separate variables?

Is this considered "bad practice" to create such a function:

// $arr_member_fields['first_name'] = $_POST['first_name'];
// $arr_member_fields['last_name']  = $_POST['first_name'];
// $arr_member_fields['email']      = $_POST['email'];
// $arr_member_fields['dob']        = $_POST['dob'];
// $arr_member_fields['gender']     = $_POST['gender'];

function update_member($int_member_id $arr_member_fields)
{
    //some code
}

Or you need to create a function without an array and just use variables - for example:

function update_member($int_member_id, $str_first_name, $str_last_name, str_email, $str_dob, $chr_gender)
{
    //some code
}

The reason I prefer the first method (the one that has an array) is that I always have the ability to iterate over the array to insert / update the database.

It is very curious to know other peoples in this regard.

+3
source share
5 answers

. , . , ?

, .

+1

, . , .

, , . , , , ..

0

. , - , ( , 6 ). , - .

, , . /?

, , . , .

, , - . , .

0

, IDE , , . , , , , . , . " name_ first first_?" -, , , , .

0

, , , . , , , , , .

, - PHPDocumentor, IDE. .

, , , .

0

All Articles