Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12521 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65267 invoked by uid 1010); 1 Sep 2004 08:15:07 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 63798 invoked by uid 1007); 1 Sep 2004 08:14:50 -0000 Date: 1 Sep 2004 08:14:50 -0000 Message-ID: <20040901081450.63790.qmail@pb1.pair.com> To: internals@lists.php.net X-WebNews-Posting-Host: 62.200.225.12 References: <20040831173813.7677.qmail@pb1.pair.com> X-Posted-By: 212.204.217.151 Subject: Re: [PHP-DEV] New function request - Variable parsing a string From: herbert@groot.jebbink.nl (Herbert Groot Jebbink) Rasmus Lerdorf wrote: >> To speed up a homebuild PHP framework I would like to have a new >> function that expands a string with the PHP variables in it, just like >> how variable parsing is done for a double-quotes string. > http://nl.php.net/parse_str I don't want to parse variables FROM a string but I want to parse them INTO a string as described on the page: http://ie.php.net/manual/en/language.types.string.php#language.types.string.parsing Below a PHP example that shows the function I want. xyz = '789'; $string = '* {$abc} * {$klm[\'klm\']} * {$xyz->xyz} *'; $result = parseVarsIntoString ($string); echo $result; function parseVarsIntoString ($string) { extract($GLOBALS); eval('$result = "' . str_replace('"', '\\"', $string) . '";'); return $result; } ?> Greetings, Herbert > > > On Tue, 31 Aug 2004, Herbert Groot Jebbink wrote: > >> Hi, >> >> To speed up a homebuild PHP framework I would like to have a new >> function that expands a string with the PHP variables in it, just like >> how variable parsing is done for a double-quotes string. >> >> string VariableParsingString ( string string ) >> >> Currently I do it with the next eval statement. >> >> eval('$result = "' . str_replace('"', '\\"', $string) . '";'); >> >> Greetings, Herbert >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >>