Hi!
I get the message that ereg_replace() is deprecated.
- this is the example code (i used this code to learn how to use preg_replace)
<?php $string = "Subtitle of first. <!-- [-list_ini-] -->Paragraph<!-- [-list_fin-] -->. The second paragraph"; echo "Original Text: <br />".$string."<br />------------<br />"; $output1 = ereg_replace(".*<!-- \[-list_ini-\] -->(.*)<!-- \[-list_fin-\] -->.*","\\1",$string); echo "Using ereg_replace: <br />".$output1."<br />-------------<br />"; $output2 = preg_replace("#.*(<!-- \[-list_ini-\] -->)(.*)(<!-- \[-list_fin-\] -->).*#e","'$2'",$string); echo "Using preg_replace: <br />".$output2."<br />"; //old funcion shows: 'Paragraph', it means: '$2', and preg_replace too... ?>
- So, I want to change the following code, to use preg_replace... but didn't work!
In this case, i don't know why the función don't return only $2;
Returns: text before ($1), text that i need [the row] ($2), and the text after($3)
if somebody help me... i will be happy!!<?php $string = ' <table align="center" width="775" id="tabla_gral"> <tr class="fila_titular"> <th width="50">Id</th> <th width="150">Nombre</th> </tr> <!-- [-listado_ini-] --> <tr class="fila_contenido [-fila-]"> <td width="50" class="centro"[-editando_auxiliar-]>[-id-]</td> <td width="150">[-nombre-]</td> </tr> <!-- [-listado_fin-] --> </table>'; echo "Original Text: <br />".$string."<br />------------<br />"; //-------------------------------------------------------- $listado1 = ereg_replace(".*<!-- \[-listado_ini-\] -->(.*)<!-- \[-listado_fin-\] -->.*","\\1",$string); // ereg_replace deprecated echo "Using ereg_replace: <br />".$listado1."<br />-------------<br />"; $listado2 = preg_replace("#.*(<!-- \[-listado_ini-\] -->)(.*)(<!-- \[-listado_fin-\] -->).*#e","$2",$string); echo "Using preg_replace: <br />".$listado2."<br />-------------<br />"; /* i want that $listado has "only" the row: <tr class="fila_contenido [-fila-]"> <td width="50" class="centro"[-editando_auxiliar-]>[-id-]</td> <td width="150">[-nombre-]</td> </tr> */ ?>
thanks for advance!!
Andrea - So, I want to change the following code, to use preg_replace... but didn't work!