Re: Newbie needs help

From: Date: Thu, 07 Jan 2010 08:32:55 +0000
Subject: Re: Newbie needs help
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-300872@lists.php.net to get a copy of this message
Great. Ok. Thanks. [I'm a top quoter)]. I'll look at it. This was my dirty way of hacking it: if (($current_user->id == 0) && ($user_ID == 0)) { $content = str_replace('<!--protected-->', '<b>Protected <!--', $content); $content = str_replace('<!--/protected-->', '--> Content</b> <a href="/wp-login.php">[Log in here</a>]', $content); } Cheap & Dirty and need refinement :p viraj wrote:
try http://www.php.net/manual/en/function.preg-replace-callback.php. you need to read a bit on 'regular expressions' http://www.gskinner.com/RegExr/ will be handy in crafting a suitable regex to capture your 'tags' ~viraj On Thu, Jan 7, 2010 at 2:16 PM, John Taylor-Johnston <John.Taylor-Johnston@cegepsherbrooke.qc.ca> wrote:
$content = "... a bunch of text with some<!--protected-->protected information<!--/protected--> with some more text with some more <!--protected--><table><tr><td>more protected text</td></tr></table><!--/protected--> and even<!--protected--><b>some protected content>b><!--/protected-->"; I want to replace any content between these tags: <!--protected--><!--/protected--> with say $replacewith = "<strong>protected content</strong>"; $content = " a bunch of text with some<strong>protected content</strong> with some more text with some more<strong>protected content</strong> and even<strong>protected content</strong>"; It's a little more involved than str_replace which is about the limit of my knowledge. Any takers - to take pity on me? I'm trying to figure out some funky WordPress stuff as it is. John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
     


« previous php.general (#300872) next »