- array_column: documentation ( source)
- array_multisort: documentation ( source)
- print_r: documentation ( source)
<?php
$array = array (
0 =>
(object)array(
'tenure' => '1 year to less than 2 years'
),
1 =>
(object)array(
'tenure' => '10 years to less than 15 years'
),
2 =>
(object)array(
'tenure' => '15 years or more'
),
3 =>
(object)array(
'tenure' => '2 years to less than 5 years'
),
4 =>
(object)array(
'tenure' => '5 years to less than 10 years'
)
);
array_multisort(array_column($array, 'tenure'), SORT_ASC, SORT_NATURAL, $array);
print_r($array);