On Fri, 18 Jul 2003, Curt Zirzow wrote:
} btw, you know you can do this in one step:
}
} $message = preg_replace("/\[(i|b)\](.*?)\[\/(i|b)\]/si", "<\$1>\$2</\$3>", $message);
Doh! Thanks for the tip...that'll save some lines of code :)
} > $patterns[3] = "#\#\#\#Image(.*?)\#\#\##si";
} > // this matches just fine strings like ###Image1### and ###Image2###
}
} I would change mabey make sure you catching a digit and the serpator for
} readabilty /###Image(\d+)###/si
Ok. Changed it and you're right - much easier to understand what the
patern is being searched.
} > [...]
} > if ($_GET[ppdid] != "") { // the ppdid var is passed in the URL
} > $sel_image = "SELECT * from ppd_photos where ppd_id = '$_GET[ppdid]' AND
place_holder = '$thephoto[0]'";
} > // in this case, the page with a ppdid of '3' has 2 images, who's
} > // placeholders are: ###Image1### and ###Image2###
} > $sel_image_result = safe_query($sel_image);
} > $sel_image_row = mysql_fetch_array($sel_image_result);
} > $image_id = $sel_image_row["image_id"];
} > $image_name = $sel_image_row["image_name"];
} > $caption = $sel_image_row["caption"];
} > $width = $sel_image_row["width"];
} > $height = $sel_image_row["height"];
} > $image_alignment = $sel_image_row["image_alignment"];
} > $replacements[3] = "<br><table border=0 cellspacing=2 cellpadding=0
[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....";
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.
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:
$message = preg_replace($patterns, $replacements, $message);
Thanks for your help with this!
/vjl/
--
Vince LaMonica UC Irvine, School of Social Ecology
W3 Developer <*> 116 Social Ecology I, Irvine, CA 92697
[EMAIL PROTECTED] http://www.seweb.uci.edu/techsupport
Your mouse has moved. Windows NT must be restarted for the
change to take effect. Reboot now? [ OK ]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php