Hello!
I'm trying to transform this:
http://link_brochure/1/2 OR link_brochure/1/2
into this:
class="show-brochure" href="http://localhost/main/brochure/1/2"
But I'm a rookie when it comes about regular expressions... Any ideas?
Thanks!
Hello!
I'm trying to transform this:
http://link_brochure/1/2 OR link_brochure/1/2
into this:
class="show-brochure" href="http://localhost/main/brochure/1/2"
But I'm a rookie when it comes about regular expressions... Any ideas?
Thanks!
I'd just use str_replace to replace 'main/' with 'link_', then 'a ' with 'a class="show-brochure"'.
On iPad, so can't be bothered to type code, but look up str_replace, and you'll get the idea!
Something like this?
$str=preg_replace(
'{(?:http://)?link_brochure/(\d+)/(\d+)}',
'class="show-brochure" href="http://localhost/main/brochure/$1/$2"',
$str);
Edit: updated following question edit (Thanks Peter).