Reputation: 369
i have this array
$array["4E-952778"][0]['fileName'] = "File 1";
$array["4E-952778"][0]['product'] = "Muse On Demand";
$array["4E-952778"][1]['fileName'] = "File 2";
$array["4E-952778"][1]['product'] = "Muse On Demand";
$array["15210"][0]['fileName'] = "File 3";
$array["15210"][0]['product'] = "4Manager";
$array["15210"][1]['fileName'] = "File 4";
$array["15210"][1]['product'] = "4Manager";
and im trying to sort it using uasort()
this way:
uasort($array, function ($a, $b) {
return strcmp($a['product'], $b['product']);
});
but im getting an error: undefined index product
Upvotes: 2
Views: 246
Reputation: 72269
Try this:-
uasort($array, function ($a, $b) {
$i=0;
return strcmp($a[$i]['product'], $b[$i]['product']);
});
Upvotes: 1