I have a array like this:
$str=
Array
(
[No] => 101
[Paper_id] => WE3P-1
[Title] => \"a1\"
[Author] => ABC
[Aff_list] =>
Thanks to crater and Fabio's answer. I updated the code to check if the size of the key is not greater than one (1), underscore will not be appended.
function _group_by($array, $keys=array()) {
$return = array();
$append = (sizeof($keys) > 1 ? "_" : null);
foreach($array as $val){
$final_key = "";
foreach($keys as $theKey){
$final_key .= $val[$theKey] . $append;
}
$return[$final_key][] = $val;
}
return $return;
}