This approach may not be general enough to account for all possible periodic boundary conditions, but it might be useful to consider nonetheless. If your periodic box is a parallelepiped (the volume enclosed by 3 sets of parallel planes), it can be defined in terms of 3 vectors. Let's call them $\vec a$, $\vec b$, and $\vec c$.

(image courtesy of Wikipedia)
If you define your coordinates such that $\vec a$, $\vec b$, and $\vec c$ are all drawn from the origin in the figure above, then there exists an invertible linear transform defined by a matrix $A$ that transforms your periodic box into the unit cube $x,y,z\in[0,1)$ We can find this matrix from the fact that associated inverse transform goes back to your original box, mapping the coordinate vectors $\hat x$, $\hat y$, and $\hat z$ (or $\hat i$, $\hat j$, $\hat k$ if you prefer) to $\vec a$, $\vec b$, and $\vec c$ respectively. That is:
$$A^{-1}\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix} = \vec a,\ \ \ A^{-1}\begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix} = \vec b,\ \ \ A^{-1}\begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} = \vec c$$
Since these unit vectors just take the 1st, 2nd, or 3rd column of $A^{-1}$, it follows that $A^{-1}$ is just a matrix whose columns are $\vec a$, $\vec b$, and $\vec c$. We can calculate the inverse of this matrix and obtain are original transform $A$. Left multiplying our coordinate vector (which I'll call $\vec x$) by $A$ allows us to get a new vector in our normalized coordinates $\vec x' = A\vec x$. Imposing periodic boundary conditions on $\vec x'$ amounts to taking each coordinate modulo 1, since our periodic box in $\vec x'$ is the unit cube. Depending on what you're doing, it may be useful to do your computations in $\vec x'$ coordinates or simply compute $A\vec x$ each time to check if you have moved out of the periodic box. If you have, you can take the coordinates of $\vec x'$ modulo 1 and transform back to $x$.
I can't comment on the computational efficiency of this approach vs others, but it seems like a conceptually simple way to deal with the types of boundary conditions you mention. Let me know if there's anything I can add.