Railroad ties are treated with chemical preservatives, such as creosote and chromated copper arsenate. Both of these chemicals are banned for residential use, and they're potentially harmful to humans and plants.
Pressure-treated lumber intended for residential use is now typically treated with borates or copper-based preservatives. The most common preservative for new pressure-treated lumber is now alkaline copper quaternary (ACQ), which contains no arsenic and has a low level of toxicity. According to the American Wood Protection Association and the U.S. Environmental Protection Agency, lumber treated with ACQ is safe for garden use. Its durability and nontoxicity make it among the best woods for raised garden beds.