$pattern = '%\[amp (.*?)\](.*?)\[\/amp\]%s';
preg_match_all($pattern, $content, $matches);
for ($loop1 = 0; $loop1 < sizeof($matches[1]); $loop1++)
{
$protected_content = $matches[2][$loop1];
$fields = explode("|", $matches[1][$loop1]);
for ($loop2 = 0; $loop2 < sizeof($fields); $loop2++){
$colums = explode("=", $fields[$loop2]);
for ($loop3 = 0; $loop3 < sizeof($colums); $loop3++){
switch($colums[$loop3]) {
case "error":
$error = trim($colums[$loop3+1]);
break;
case "pid":
$pid = trim($colums[$loop3+1]);
break;
case "showbox":
$showbox = trim($colums[$loop3+1]);
break;
default:
break;
}
}
}
If I use the reg expression you gave me then doesn't enter in the for loop at all. I use this content in the front end which is passed to the function that parses using regex code above.
[amp showbox=true|error=You must be logged in, <b>with an active subscription</b>, to access this file. |pid=53]<a href=http://yahoo.com>Click here to download this lesson</a>[/amp]