Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
and does testing merely mean running it 100 000 times and clocking it?

// using preg_replace :

$s = '
<select name="color">
<option value="">choose
<option value="red">red
<option value="green">green
<option value="blue">blue
<option value="yellow">yellow

{  $c=$_POST['color'];
   $s=preg_replace('/(value="'.$c.'")/','$1 selected',$s);

echo $s;

// using loop :


echo '<select name="color">';
echo '<option value="">choose';
foreach($colors as $c){
  echo '<option value="'.$c.'"';
    echo ' selected';
  echo '>'.$c;

echo '</select>';

Re: selecting

zorro wrote:
Quoted text here. Click to load it

You could, it would give you some valuable information. 100 000 is a bit
much though.

Rule of thumb: regexes are slow, don't use them if other simple code can do
the job as easily and dynamically.

Rik Wasmus

Site Timeline