This PHP (5.3) code is intended to take an array and a key as inputs, and return an array of the values paired with that key‡
function valuelist($array, $array_column) {
$return = array();
foreach($array AS $row){
$return[]=$row[$array_column];
};
return $return;
};
Can this be improved in terms of processing speed?
‡-For example, given:
$get_role_action = array(
array("ACTION_CD" => "RETURN_PETITION"),
array("ACTION_CD" => "UNLOCK_RECORD"),
array("ACTION_CD" => "ACKNOWLEDGE"),
array("ACTION_CD" => "REQUEST_POST_ACTION"),
array("ACTION_CD" => "CHANGE_REQUEST_TYPE")
);
$variables['role_action_list']=valuelist($get_role_action, 'ACTION_CD');
should yield:
["role_action_list"]=>
array(17) {
[0]=>
string(15) "RETURN_PETITION"
[1]=>
string(13) "UNLOCK_RECORD"
[2]=>
string(11) "ACKNOWLEDGE"
[3]=>
string(19) "REQUEST_POST_ACTION"
[4]=>
string(19) "CHANGE_REQUEST_TYPE"
}