Ho trovato questo esempio e ho capito abbastanza bene come sostituire dei pezzi facendone l'eval.
Non riesco però ad applicarlo al mio caso. Ossia prendere tutto ciò che sta dentro <?php ... ?> e fare l'eval..Codice PHP:<?php
$string = 'This is the {_FOO_} bought to you by {_BAR_}';
$template_vars=array("FOO" => "The PHP Way", "BAR" => "PHPro.orG");
$string = preg_replace("/{_(.*?)_}/ime", "\$template_vars['$1']",$string);
echo $string;
?>![]()

Rispondi quotando