Forum Moderators: coopster

Message Too Old, No Replies

Find & Replace

         

MattSEOBrown

6:55 pm on Nov 18, 2009 (gmt 0)

10+ Year Member



Hi,

I am working with Wordpress and I would like users to be able to post a message with an SKU number (6 digits) along with text of their choosing.

What I need to do is find the SKU number(s) in the post (there may be more than one) and replace with an image and a link e.g.
<a href="http://www.example.com/SKU_Number"><img src="http://www.example.com/SKU_Number.jpg" /></a>

SKU_Number in the image and the link being the actual SKU number in the post.

Let me know if you need any more detail.

Thanks in advance

dreamcatcher

7:08 pm on Dec 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi MattSEOBrown, welcome to WebmasterWorld. :)

Looks like we do need a little more information. If you want to read the page into a string you can use str_replace [php.net].

Not really sure about Wordpress as I don`t use it.

dc

FourDegreez

2:43 am on Dec 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



preg_replace('/([0-9]{6}/', '<a href="http://www.example.com/$1"><img src="http://www.example.com/$1.jpg" /></a>', $text);