translating a function from Perl to PHP

From: Date: Wed, 25 Apr 2001 22:16:54 +0000
Subject: translating a function from Perl to PHP
Groups: php.general 
Request: Send a blank email to php-general+get-50376@lists.php.net to get a copy of this message
Hi everyone, I'm a good perl programmer, but I'm not able to translate this small Perl program to PHP: $testo = 'Hi <%NOME%>, how are you? Tomorrow I\'ll go to <%DESTINAZIONE%> with <%AMICO%>!'; %mioArray=( 'NOME' => 'Pippo', 'AMICO' => 'Pluto', 'DESTINAZIONE' => 'Roma'); print $testo."\n\n"; $testo =~ s/<%([a-zA-Z]*)%>/$mioArray{$1}/g; # <== this is my problem!!! print $testo."\n"; This is the output of the script: Hi <%NOME%>, how are you? Tomorrow I'll go to <%DESTINAZIONE%> with <%AMICO%>! Hi Pippo, how are you? Tomorrow I'll go to Roma with Pluto! HELP ME PLEASE!!! :)

« previous php.general (#50376) next »