I need to sort the array in descending order. I use asort in order to save proper reference to keys. However, $ind is null. Why?
$selected = array();
for ($i=0; $i<10; $i++) {
$selected[] = array('ind' => $i, 'rank' => rand(0,10));
}
asort($selected, SORT_NUMERIC);
$ind = $selected['ind'];
After your
for()loop you have something like this:This is called a multidimensional array, and you access the inner arrays in a similar way as you do single-dimensional arrays.
You can access it with a
$array[0]['ind'], or possibly even aforeach()loop so you get all the values.Now the
$indarray has all the values in a single-dimensional array, that you can access with:$ind[0]or$ind[1], giving you theindvalue.