php - sorting array by sub object -
this question has answer here:
- sort array of objects object fields 12 answers
- how can sort arrays , data in php? 7 answers
in php....how can sort following example "attachment_id" under each individual array [image][videoembed][etc] [image] ordered 691,692,699 , [videembed] ordered if there more 1...etc, etc.
i hope makes sense.
thank all.
( [image] => array ( [0] => stdclass object ( [title] => 77007_433592946695465_6701985_n.jpg [attachment_id] => 699 ) [1] => stdclass object ( [title] => 253163_10151127010009522_736212653_n.jpg [attachment_id] => 692 ) [2] => stdclass object ( [title] => 263893_10150217397944522_4550001_n.jpg [attachment_id] => 691 ) ) [videoembed] => array ( [0] => stdclass object ( [title] => youtube [attachment_id] => 692 ) ) [] => array ( [0] => stdclass object ( [title] => yada.jpg [attachment_id] => 688 ) ) )
you can use usort , give custom comparsion function.
Comments
Post a Comment