okey dokey, here goes:

this gets really complicated to explain without showing the code, which I really can't do (damned NDA's) and ultimately it's a bit big to post anyhow. But I'm going to try.

I let the user specify a number of rows to input 2 pieces of data. I then replace a template containing one row with that number of replacement rows when displaying the form. In the process of creating the final data to send to the user I of course have to fill in a couple of details.

So I start with a base form field:
<input type="hidden" value="!value!" name="!field_id!"> !value! <input type="text" name="!field_id![]">

So that line has to be repeated as many times as the user enters. With the !**! values being replaced by the correct information. The !value! needs to just be a simple incremented count. What I was hoping to do was build an array of the correct data for each row, then insert it into the template. The template doesn't distinguish each row at all, so I am trying to shove different data in for each row, when at this stage, I just have a template that looks roughly like:

<table>
<tr>
<td>!insert_row!</td>
</tr>
<tr>
<td>!insert_row!</td>
</tr>
<tr>
<td>!insert_row!</td>
</tr>
</table>

I was hoping the str_replace with an array would work here, but it isn't, so I am looking for other options. I know I have a way to do it now, by just looping through and replacing them one by one. I was just trying to find a little bit more elegant solution I guess.

Thanks,
Wes


On Thursday, December 26, 2002, at 08:14 PM, John W. Holmes wrote:

In using str_replace, I glanced at the manual and found that it can
take arrays for it's arguments. Great! I thought that I could have a
single search string, an array of replacement vars, and no subject. It
would then replace each successive instance of the search string with
the next element in the replacement array.

Sadly this is not the case.

Anyone have any recommendations on how to go about this? Best idea
using p/ereg_replace? Or just a loop system in which I replace the
first instance of the string each time?

I'm not great at p/ereg yet, anyone have any pointers?
Can you explain exactly what you want replaced and with what? Give an
example of the string and what will be replaced and what it will be
replaced with. Then someone can write/help with the regex.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



--
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

Reply via email to