Newbie needs help

Newbie needs help

am 07.01.2010 09:16:59 von John Taylor-Johnston

$content = "... a bunch of text with some protected
information with some more text with some more

more protected
text
and even some
protected content>b>";

I want to replace any content between these tags:

with say

$replacewith = "protected content";


$content = " a bunch of text with some protected
content
with some more text with some more protected
content
and even protected content";

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

Re: Newbie needs help

am 07.01.2010 09:24:51 von kalinga

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
wrote:
>
> $content = "... a bunch of text with some protected
> information with some more text with some more
>

more protected
> text
and even some
> protected content>b>";
>
> I want to replace any content between these tags:
>
> with say
>
> $replacewith = "protected content";
>
>
> $content = " a bunch of text with some protected content
> with some more text with some more protected content and
> even protected content";
>
> 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
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Newbie needs help

am 07.01.2010 09:32:55 von John Taylor-Johnston

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 ', '--> Content href="/wp-login.php">[Log in here]', $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
> wrote:
>
>> $content = "... a bunch of text with someprotected
>> information with some more text with some more
>>

more protected
>> text
and evensome
>> protected content>b>";
>>
>> I want to replace any content between these tags:
>>
>> with say
>>
>> $replacewith = "protected content";
>>
>>
>> $content = " a bunch of text with someprotected content
>> with some more text with some moreprotected content and
>> evenprotected content";
>>
>> 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
>>
>>
>>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php