0

a $request reaches my controller:

array:2 [
  0 => Illuminate\Http\UploadedFile {#1512
    -test: false
    -originalName: "test.test"
    -mimeType: "application/octet-stream"
    -error: 0
    #hashName: null
    path: "C:\xampp\tmp"
    filename: "phpCD1C.tmp"
    basename: "phpCD1C.tmp"
    pathname: "C:\xampp\tmp\phpCD1C.tmp"
    extension: "tmp"
    realPath: "C:\xampp\tmp\phpCD1C.tmp"
    aTime: 2020-08-25 14:34:24
    mTime: 2020-08-25 14:34:24
    cTime: 2020-08-25 14:34:24
    inode: 0
    size: 1973584
    perms: 0100666
    owner: 0
    group: 0
    type: "file"
    writable: true
    readable: true
    executable: false
    file: true
    dir: false
    link: false
    linkTarget: "C:\xampp\tmp\phpCD1C.tmp"
  }
  1 => Illuminate\Http\UploadedFile {#1506
    -test: false
    -originalName: "logo.png"
    -mimeType: "image/png"
    -error: 0
    #hashName: null
    path: "C:\xampp\tmp"
    filename: "phpCD2C.tmp"
    basename: "phpCD2C.tmp"
    pathname: "C:\xampp\tmp\phpCD2C.tmp"
    extension: "tmp"
    realPath: "C:\xampp\tmp\phpCD2C.tmp"
    aTime: 2020-08-25 14:34:24
    mTime: 2020-08-25 14:34:24
    cTime: 2020-08-25 14:34:24
    inode: 0
    size: 9673
    perms: 0100666
    owner: 0
    group: 0
    type: "file"
    writable: true
    readable: true
    executable: false
    file: true
    dir: false
    link: false
    linkTarget: "C:\xampp\tmp\phpCD2C.tmp"
  }
]

I need to process the image first always, so no matter how the files are uploaded, id like to resort the array so the file with an original name ending in .png is first in the array.

But I am unable to find an array resort that can be done based on the value of the specific key. Does it all need to be done manually and I need to remake the array by hand every time or is that functionality that I have not noticed?

Monty
  • 39
  • 7
  • https://stackoverflow.com/questions/17364127/how-can-i-sort-arrays-and-data-in-php should answer all questions you could possibly have about sorting arrays in PHP. – CBroe Aug 25 '20 at 14:56

0 Answers0