This is an odd question because I don’t know what to call it! I have an array with a list of numbers. These numbers are automatically detected, so I can’t set them.
The numbers come in ranges like “001, 002, 003, 004, 005, 006” or “001, 003, 004“.
Note that in the first list of numbers, they all go up (1,2,3,4,5,6) but in the second one they are less ordered (1, 3, 4).
My complicated question is this: How do I detect the first available array entry? For the first one, I would want “007” and for the second one “002“. How on earth do I detect this and add an array element to fill the slot??!
The system supports unlimited slots, so there is no actual list of slots to compare against.
Here is my code so far:
$currentunits = array("001", "003", "004", "006");
$currentunits = array_diff($currentunits, range("001", "999"));
echo "<pre>";
print_r($currentunits);
Thanks in advance, and I hope I have not confused you!
Assuming that your 001 is the string
"001"and not the number1(etc):