[Solved] group key based on value array php [closed]


Is this what you are looking for?

$data = array();
$data["user-insert-resp.php"] = "123";
$data["login.php"] = "123";
$data["project-view.php"] = "13";


$flipped_data = array();
foreach($data as $key=>$value){
    if(!isset($flipped_data[$value])){
        $flipped_data[$value] = array();
    }
    $flipped_data[$value][] = $key;
}

Result:

Array ( 
[123] => Array ( [0] => user-insert-resp.php [1] => login.php ) 
[13] => Array ( [0] => project-view.php )
)

solved group key based on value array php [closed]