Re: Smarty news/article admin?
| From: | Peter Bowyer | Date: | Sat, 09 Mar 2002 08:24:24 +0000 |
| Subject: | Re: Smarty news/article admin? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2990@lists.php.net to get a copy of this message | ||
At 03:14 PM 3/8/02 -0600, Monte Ohrt wrote:
(untested) preg_match_all("/\[image [^\]]+\]/",$contents,$match); $match[0] should contain an array of your matches. You might just use a preg_replace to get your tags in there. $contents = preg_replace("/\[image id\=([^ ]+)( [^\]]+)?\]/","<img src=\"\\1\"\\2>",$contents);Thanks, but I was trying to take it one step further and do what Smarty does when it passes values to a custom function - so parsing the following tag [image id=56 align='left'] would pass to the defined function an array containing id => '56' align => 'left' I'd prefer to do it this way than the one you showed above because this gets rid of the problem of quoting attributes in the HTML (it needs to be align="left" not align='left' or align=left) Regards, Peter. ---oOo--- sendcard - The free PHP e-card solution http://sendcard.resource-locator.com ---oOo---