RE: [PHP] translating a function from Perl to PHP
At 4/26/2001 05:33 AM, ..s.c.o.t.t.. [gts] wrote: i tried to do it myself and nearly fell off my chair becuase PHP makes you jump through hoops to do such a simple thing print preg_replace('/%([a-zA-Z]*)%/e', \$mioArray['$1'], $testo); i never could understand why other languages made regular expressions so convoluted. why not just support the =~ binding operator instead of that awful function syntax...? Perhaps this is in every Perl programmer's dream. :-) But perhaps not every language has the luxury/willingness to include regular expressions in the core language, since they think *that* is convoluted. Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] translating a function from Perl to PHP
i tried to do it myself and nearly fell off my chair becuase PHP makes you jump through hoops to do such a simple thing print preg_replace('/%([a-zA-Z]*)%/e', \$mioArray['$1'], $testo); i never could understand why other languages made regular expressions so convoluted. why not just support the =~ binding operator instead of that awful function syntax...? -Original Message- From: Black Dragon [mailto:[EMAIL PROTECTED]] Subject: [PHP] translating a function from Perl to PHP 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; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] translating a function from Perl to PHP
You've been my salvation!! thanks! :) print preg_replace('/%([a-zA-Z]*)%/e', \$mioArray['$1'], $testo); i never could understand why other languages made regular expressions so convoluted. why not just support the =~ binding operator instead of that awful function syntax...? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]