Using array_multisort here might be possible with some tricks, but it’s actually more for sorting multiple arrays (or array-dimensions) at once… so I think in this case, it would be much easier to use usort instead:
usort($foodArray1, function ($a, $b) {
return $a['name'] > $b['name'];
});
$foodArray1 = array(
0=> array('name' => 'Zucchini', 'description' => 'A delicious healthy vegetable', 'image' => 'zucchini.gif'),
1=> array('name' => 'Apple', 'description' => 'One of these a day keeps the doctor away!', 'image' => 'apple.gif'),
2=> array('name' => 'Pizza', 'description' => 'Isnt it weird that pizza is round, but is cut into triangles and comes in a square box?', 'image' => 'pizza.gif')
);
usort($foodArray1,function($a1,$a2) {
return strnatcasecmp($a1['name'],$a2['name']);
});
foreach($foodArray1 as $food) {
echo $food['name'] . "\n";
}
OOPS: @m3g4p0p beat me to it. Though his return statement is not quite right.