to reduce overhead used by the tables, mysql will insert the data wherever it can, in this case it sees an empty spot from the previous delete so it puts the data there.
it has nothing to do with php, but is actually behavior of mysql.
if you really need the item to be added at the end, and you have no column that can identify when the record was inserted, the query
optimize table tablename
will remove the empty space and then your next insert will be at the end.