Petrified wood forms when wood is quickly buried in sand or mud, typically in a river channel during a flood. In some cases, however, wood can be buried in a beach or rafted into a deep-marine environment. Under the right conditions, silica (SiO2) dissolved in groundwater is "templated" on the organic material in the wood; in addition, some silica crystallizes within the pore spaces in the wood. Depending on the timing of the various processes and the degree to which they progress, the wood can be fragile and splintery or completely solid, and the cellular structure of the wood can be perfectly preserved or completely destroyed.
Some "fossil wood" in Oklahoma, while it looks and "feels" like petrified wood is, in fact, not petrified wood. Rather, it is a "cast" that forms when wood buried in sediment decays, leaving a mold that preserves many of the features present on the outside of the wood. If the mold fills with sediment which then hardens, the cast that forms resembles petrified wood but did not form as a result of silica-templating or pore-filling of organic material.