Welcome to the forum
Rangers used the 2.5l SOHC 4cyl Lima engine in 1999, 117 horse power
In 2001 Rangers got the 2.3l DOHC 4cyl Mazda L engine, 143 horse power, and had this engine until 2012, last year of the Ranger
The 2.3l DOHC was first used in Rangers, so any 4cyl from 1999 wouldn't be same engine.
The engines are not related.
You would need the Motor, tranny, computer and wiring.
Possible yes, practical no.
'08 computer runs the dash instruments, so loads of issues swapping computers
Also losing 30HP for the trouble
Better to buy the low miler and then resell it for a profit and use that money for 2.3l DOHC Duratec engine, repair or replace