I am trying to sort this array but at the same time, I am trying to change the index and all elements unchanged.
I want to sort the array by [name]. So array[7] with Cross Cutting Functions
would be the first node and so on ...
This is the array:
Array
(
[0] => stdClass Object
(
[tid] => 992
[vid] => 70
[name] => Global People
[description] =>
[format] => filtered_html
[weight] => 0
[depth] => 0
[parents] => Array
(
[0] => 0
)
)
[1] => stdClass Object
(
[tid] => 1206
[vid] => 70
[name] => Global Department Head
[description] =>
[format] => filtered_html
[weight] => 1
[depth] => 0
[parents] => Array
(
[0] => 0
)
)
[2] => stdClass Object
(
[tid] => 986
[vid] => 70
[name] => Global Private Leaders
[description] =>
[format] => filtered_html
[weight] => 2
[depth] => 0
[parents] => Array
(
[0] => 0
)
)
[3] => stdClass Object
(
[tid] => 1208
[vid] => 70
[name] => Service Line Partnership
[description] =>
[format] => filtered_html
[weight] => 3
[depth] => 0
[parents] => Array
(
[0] => 0
)
)
[4] => stdClass Object
(
[tid] => 984
[vid] => 70
[name] => Digital Stakeholders
[description] =>
[format] => filtered_html
[weight] => 4
[depth] => 0
[parents] => Array
(
[0] => 0
)
)
[5] => stdClass Object
(
[tid] => 990
[vid] => 70
[name] => Regional Team
[description] =>
[format] => filtered_html
[weight] => 5
[depth] => 0
[parents] => Array
(
[0] => 0
)
)
[6] => stdClass Object
(
[tid] => 988
[vid] => 70
[name] => Digital Team
[description] =>
[format] => filtered_html
[weight] => 6
[depth] => 0
[parents] => Array
(
[0] => 0
)
)
[7] => stdClass Object
(
[tid] => 1210
[vid] => 70
[name] => Cross Cutting Functions
[description] =>
[format] => filtered_html
[weight] => 7
[depth] => 0
[parents] => Array
(
[0] => 0
)
)
)
This is what I tried:
(But it's not working)
foreach ($terms as $key => $row) {
$temp_array[$key] = $row['name'];
}
array_multisort($temp_array, SORT_ASC, $data);
Thanks.