Categories > TinyButStrong general >

How to use eregi_replace

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Ivor Humphreys
Date: 2006-02-27
Time: 11:04

How to use eregi_replace

TBS is utterly superb. I'm new to PHP/MySQL and had been bemoaning the apparent lack of a class that could do the equivalent of the much admired ASP/VBScript open source object VBSdb, which I've been using for the past two years. I chanced upon TBS via a mention in the ezSQL forum a week ago and it has made everything I need to do not only feasible but achieveable with sophistication. Thank you so much. See http://goodimprint.org/tbs2/ for a test application I put together in remarkable short time. (Feel free to experiment if it's of interest, as none of the data is required.)

One question: Could you advise on how to use eregi_replace in the TBS ondata Block parameter?

Kind regards,

Ivor H
By: Skrol29
Date: 2006-02-27
Time: 13:00

Re: How to use eregi_replace

Hi Ivor,

Here is an example of how you could use eregi_replace() to modify a colum  of a query at merging :

HTML:
<tr>
  <td>[b1.title;block=tr;ondata=mycustomfct]</td>
  <td>[b1.body]</td>
</tr>

PHP:
function mycustomfct($BlockName,&$CurrRec,$RecNum) {
  // removing excess spaces in column 'body'
  $CurrRec['body'] = eregi_replace(' +',' ',$CurrRec['body']);
}
By: Ivor Humphreys
Date: 2006-03-04
Time: 22:48

Re: How to use eregi_replace

Many thanks. After much trial, error and frustration I discovered that ondata only works if the template has the extension .htm

If it has .html it will not work.

Kind regards,

Ivor H
By: Skrol29
Date: 2006-03-05
Time: 23:03

Re: How to use eregi_replace

> Many thanks. After much trial, error and frustration I discovered that
> ondata only works if the template has the extension .htm
> If it has .html it will not work.

I don't think so. TBS does not matter the extension of the file. It could even be .txt or .whatyouwant
By: Ivor Humphreys
Date: 2006-03-06
Time: 09:32

Re: How to use eregi_replace

Hmm. You're right of course. It must have been a coincidence and that I fixed
my problem with someting else at the same moment. So much to learn... !