If your array is always the same (key 2 always === first_name and key 3 always === last_name), you can use array notation to stop the error:
$user = User::where('first_name', 'LIKE', "%".$array[2]."%")->where('last_name', 'LIKE', "%".$array[3]."%")->first();
But you've said that the keys are specifically NOT always the same. You will need to write something to normalize the data in advance if this is the case. If there are always a 'type' like 'employee' and a limited number of choices for what this might be, you can eliminate based on a match to the type:
foreach($array as $key=>$val){
if(!in_array($val, $yourTypes)
// set the value to first or last depending on the order these come in
Or, if there is some way to standardize the array before it gets to the User pull, you should try to do this to make sure you know which value is hitting the query. Something like a common input format for a CSV file - users must set columns in an exact order - if you can correct for this, you can solve it. If there is ability to create a named key, this would also solve it, though it looks like that's not possible based on your pull from a simple string. A more radical step would be to have a mapping program for an admin to match each string manually: I.E. each string is exploded and displayed on the screen with each key number and the corresponding value, admin can choose which key is first_name, which key is last_name.
But to try to pull based on multiple different array structures where it is unknown, is likely not possible. This is why APIs will typically have specifically defined keys and output - not knowing this puts the burden on a manual intervention like the mapping thing I noted above.