Jump to content

buzzdeep

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

buzzdeep's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes, my bad..thanks. But now I'm stuck at the preg_replace part. I'm using this.. $pattern = '%\[amp (.*?)\]". $protected_content ."\[\/amp\]%s'; $form = function_login_form(); $content = preg_replace($pattern, $form, $content); ...but apparantly, preg_replace is not able to find that pattern because it doesn't replace the pattern in the content with the form. Any ideas?
  2. $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]
  3. No, didn't work It still doesn't take </ ...new line is also not working...atelast if I can make it work for closing html tag (</) that should help me for now...
  4. Hi PHP Experts...I'm new to regex expressions and facing a problem. $pattern = "/\[amp (.*?)\](.*?)\[\/amp\]/"; This is suppose to look for tags [amp showbox=true|otheroptions=false] some text [/amp] Now this word fine as long as I use the following text in the fronted: [amp showbox=true|otheroptions=false]Click here to download[/amp] But it breaks when I use any of the following: [amp showbox=true|otheroptions=false]<a href=http://someurl.com>Click here</a> to download[/amp] Possibly because of closing </a> as it has a forward slash. [amp showbox=true|otheroptions=false] Click here to download [/amp] Possibly because of new line returns. [amp showbox=true|otheroptions=false]<h3>Click here to download</h3>[/amp] Possibly because of closing </h3> as it has a forward slash. Could someone please help modify the regex expression to take care of all the three situations? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.