<?php
$array = ["Ripe Mango"=>"Yellow", "Strawberry"=>"Red", "Lemon"=>"Yellow"];
$result = [];
foreach ($array as $result[$v][] => $v);
var_export($result);
- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- array (
'Yellow' =>
array (
0 => 'Ripe Mango',
1 => 'Lemon',
),
'Red' =>
array (
0 => 'Strawberry',
),
)
preferences:
79.02 ms | 407 KiB | 5 Q