Vince LaMonica <[EMAIL PROTECTED]> wrote:
> On Fri, 18 Jul 2003, Curt Zirzow wrote:
> 
> [snip]
> } 
> } The only solution I can think of is while your looping through the
> } images they have  build more pattern/replacemen array items
> } 
> } foreach (row in db)
> }    $pattern[] = /###Image($count+1)###
> }    $$replacements[] = "<htmlstuff>$image_name</htmlstuff>";
> 
> Do you mean: 
> 
> $patterns[3] = "/###Image($count+1)###/";
> $replacements[3] = "<html stuff....";

Actually I did mean to use the $patterns[]  and $replacements[], php
will automatically increase the index for you kinda makes adding
different pattern/replacement arrays easier in any order.

The array will by default be FIFO.

> 
> The problem with this is that I don't know how many rows are going to come 
> back, since the first/only SQL statement just returns one row [whatever 
> the current image placeholder is...in this case, ###Image1###. So I need 
> to loop before I run the SQL statements. 

<snip>
>$sel_image = "SELECT * from ppd_photos where ppd_id = '$_GET[ppdid]' AND > 
>place_holder = '$thephoto[0]'";
</snip>
What does this return?

I'm a bit confused right now..


> 
> Also, using $patterns[3] again overwrites the first call to it [the one 
> you recommended i re-write for readablity]. I need to make sure the 
> $replacements[3] contains all of the html stuff, so it needs a pattern for 
> the preg_replace call later in the function:

by using the patters[] and replacements[] it will avoid the overwriting.

> 
> $message = preg_replace($patterns, $replacements, $message);


> 
> Thanks for your help with this!
> 
> /vjl/

oh, i'm feeling helpful today.. another suggestion for performance:

after the user enters in his stuff, he wants, in your CMS and before you
save it, parse it for all the special tags you have and keep track of it
somewhere.  That way when you output it (in this script) you only need
to apply the necessary pattern/replacements before outputing it to the
browser.  

Curt.
-- 


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

Reply via email to