Changing order of db results when encoding to JSON

Quite a few options you have here but the simplest I suppose would be to change your SQL query like so:

SELECT 
  0 AS id, 
  user_login AS name, 
  display_name AS tag, 
  user_status AS status 
FROM wp_users;

You can see that now we have the needed order and when you will do the $row['id'] = $i; assignment we will use that position instead of creating a new key => value.

Another solution making use of MySQL user variables:

SELECT
  @idx := @idx + 1 AS id,
  user_login AS name, 
  display_name AS tag, 
  user_status AS status
FROM wp_users
CROSS JOIN
  (SELECT @idx := 0) idx;

With the above solution you won’t need to add the PHP increment mechanism, you will get the id column already formatted as you need.