Text Organizing Help?

I need to have the php program to separate each link of text and put a word I choose in front of it on the output page,

I enter this into the text field form each word on a new line using h1 as an example but would contain letters or numbers

I want this Output so I can copy it on page and put it in a text file:

Word h1
Word h2
Word h3
Word h4
Word h5

How do I go about doing this in php? links to tutorials would be good or some examples whatever tickles your fancy. I’m not doing this for a school project or anything, I’ve been out of school for a very long time.

So are you saying you want to prepend a word $word to the matched pattern


that is exactly:
a lowercase letter h, followed by
a single integer 1-9, followed by
a new line

So it would do nothing in this case.

I was walking down the h1 when suddenly a H1
was spotted beaming down h12

Or should it?