I have peices of text on the page... Go example:
Code:
{ADDCART:[Rug Only 4|9||-5|6||]PRICE:[82.00]}
{ADDCART:[Rug Only 5|9||-6|]PRICE:[87.00]}
I want to select those and replace with a link... E.g:
Code:
<a href="products/order/cart.php?mode=add&item=Rug%20Only%204|9||-5|6||&price=82.00">Add to Cart</a>
<a href="products/order/cart.php?mode=add&item=Rug%20Only%205|9||-6|&price=87.00">Add to Cart</a>
I tried this code but it aint working...
PHP Code:
$match_count = preg_match_all("#\{ADDCART:\[(.*?)\]PRICE:\[(.*?)\]}#si", $body, $matches);
for ($i = 0; $i < $match_count; $i++)
{
$original = "";
$replace = "";
$original = "{ADDCART:[$matches[0]]PRICE:[$matches[1]]}";
$replace = "<a href=\"products/order/cart.php?mode=add&item={$matches[0]}&price={$matches[1]}\">Add to Cart</a>";
$body = str_replace($original, $replace, $body);
}
What am I doing wrong?