Wednesday, May 16, 2012

Sort a PHP array of Array based on a column value

I need to sort the following array of array based on the value of ['sort_column']. Is there a direct php function that does this or I need to use a for loop? Please assist, my brain is not working at the moment. Thanks in anticipation of a response.



Array
(
[0] => Array
(
[sender_id] => 72
[sender_persona_id] => 92
[recipient_persona_id] => 40
[has_read] => 1
[sort_column] => 92
)

[1] => Array
(
[sender_id] => 84
[sender_persona_id] => 34
[recipient_persona_id] => 40
[has_read] => 1
[sort_column] => 34
)

[2] => Array
(
[sender_id] => 90
[sender_persona_id] => 40
[recipient_persona_id] => 34
[has_read] =>
[sort_column] => 34
)

[3] => Array
(
[sender_id] => 90
[sender_persona_id] => 40
[recipient_persona_id] => 34
[has_read] =>
[sort_column] => 34
)

[4] => Array
(
[sender_id] => 90
[sender_persona_id] => 40
[recipient_persona_id] => 92
[has_read] => 1
[sort_column] => 92
)

[5] => Array
(
[sender_id] => 90
[sender_persona_id] => 40
[recipient_persona_id] => 92
[has_read] => 1
[sort_column] => 92
)

[6] => Array
(
[sender_id] => 90
[sender_persona_id] => 40
[recipient_persona_id] => 92
[has_read] => 1
[sort_column] => 92
)

[7] => Array
(
[sender_id] => 90
[sender_persona_id] => 40
[recipient_persona_id] => 92
[has_read] => 1
[sort_column] => 92
)

)




No comments:

Post a Comment