Created $keys variable to be passed by reference to stop PHP warning being shown.