I'm going mad about this. Now, i've got the following text:

--------------------------------- BEGIN TEXT ------------------------------

Let's see a very simple class sample

<?
class CTest
{
  var $variable1;  //Propiedad

  function DoThing()    //Método
  {
    echo "esto es una prueba de clase";
    echo "una clase es mejor que nada";
  }
}
?>

And this was the sample

---------------------- END TEXT -------------------------------------------


I'm using preg_replace() to replace the PHP code qith the result of doing a
highlight_string() to it. So i use this code:

preg_replace("/(.*)(<\?.*?\?>)(.*)/imse","'\\1'.highlight_string('\\2').'\\3
'",$text);

It ouputs this:

<?
class CTest
{
  var $variable1;  //Propiedad

  function DoThing()    //Método
  {
    echo 'esto es una prueba de clase';
    echo 'una clase es mejor que nada';
  }
}
?>

In colored code, as you might see.

and the weirdest of all: when i use this code:

preg_replace("/(.*)(<\?.*?\?>)(.*)/imse","''.highlight_string('\\1').''.high
light_string('\\2').''.highlight_string('\\3').''",$text);

It recognizes the \\1 and \\3 strings!!!!



Why can't i use then

preg_replace("/(.*)(<\?.*?\?>)(.*)/imse","''.strtolower('\\1').''.highlight_
string('\\2').''.strtolower('\\3').''",$text]);

or even a simpler

preg_replace("/(.*)(<\?.*?\?>)(.*)/imse","'\\1'.highlight_string('\\2').'\\3
'",$text);




I'm trying to separate the code from the rest of strings, as you might see.
Can anyone help me? I got this far, and i feel it's a very silly thing, but
i can't seem to be able to get it.

Any ideas?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to