使用php按特定顺序排序数组

时间:2014-03-18 11:55:25

标签: php arrays

我有一个数组

$user=array(
        "20163_100011100001_Guarantor_address_Proof.jpg",
        "20163_100011100001_Guarantor_Identity_Proof.jpg",
        "20163_100011100001_Guarantor_Photo.jpg",
        "20163_100011100001_Member_Address_proof.jpg",
        "20163_100011100001_Member_Identity_proof.jpg",
        "20163_100011100001_Member_Photo.jpg"
     );

我想按给定的顺序对$user数组进行排序

$order=array(
        "20163_100011100001_Member_Photo.jpg",
        "20163_100011100001_Member_Address_proof.jpg",
        "20163_100011100001_Member_Identity_proof.jpg",
        "20163_100011100001_Guarantor_Photo.jpg",
        "20163_100011100001_Guarantor_address_Proof.jpg",
        "20163_100011100001_Guarantor_Identity_Proof.jpg"
     );

1 个答案:

答案 0 :(得分:0)

从一开始就以正确的顺序填写$user是不是更好?无论如何你可以尝试这个

$order=array(user(6), user(4), user(5), user(3), user(1), user(2))