I need to find a PHP equivalent to a very familiar TCL command "subst"
(see http://www.hume.com/html84/mann/subst.html ).
This command will take a string and evaluate anything TCL inside of it
and return values.
for example, if this were my line:
[TCL]
set word {World}
set line {Hello #word#}
regsub -all {#([^#]+)#} $line {$$1} line
return [subst $line]
[/TCL]
My return should be
Hello World
and not
Hello #word#
Nor
Hello $word
Because of a requirement for my app I am having to do the same kind of
substitution variation, however, I am having to do it entirely in PHP.
I don't know of any PHP manual operated command close to TCL's
subst() but I'm open to the idea.
Here is my class method that fails to do so:
[PHP]
function &getSuccessMsg( ) { // STATIC STRING METHOD
global $section, $action, ${$section . 'LocationPath'} ,
$successMsgArra y;
if (is_array($_POS T) && @sizeof($_POST) > 0) foreach ($_POST as $key
=> $val) if (!isset(${$key} )) ${$key} = $val;
$locationPath = ($album) ? "${$section . 'LocationPath'}/$album" :
${$section . 'LocationPath'} ;
$this->fileName = ($image_name) ? $image_name : $this->fileName;
$fileName = $this->fileName; // FOR REASSIGNMENT INTO GLOBALIZED
2-DIM ARRAY FROM PROCEDURAL GLOBAL LIBRARY project_globals .inc.php
$msg = preg_replace('/#([^#]+)#/i', '$$1',
$successMsgArra y[$section][$action]);
$junk = eval('$' . 'msg = $msg;');
return $msg;
}
[/PHP]
Thanx
Phil
(see http://www.hume.com/html84/mann/subst.html ).
This command will take a string and evaluate anything TCL inside of it
and return values.
for example, if this were my line:
[TCL]
set word {World}
set line {Hello #word#}
regsub -all {#([^#]+)#} $line {$$1} line
return [subst $line]
[/TCL]
My return should be
Hello World
and not
Hello #word#
Nor
Hello $word
Because of a requirement for my app I am having to do the same kind of
substitution variation, however, I am having to do it entirely in PHP.
I don't know of any PHP manual operated command close to TCL's
subst() but I'm open to the idea.
Here is my class method that fails to do so:
[PHP]
function &getSuccessMsg( ) { // STATIC STRING METHOD
global $section, $action, ${$section . 'LocationPath'} ,
$successMsgArra y;
if (is_array($_POS T) && @sizeof($_POST) > 0) foreach ($_POST as $key
=> $val) if (!isset(${$key} )) ${$key} = $val;
$locationPath = ($album) ? "${$section . 'LocationPath'}/$album" :
${$section . 'LocationPath'} ;
$this->fileName = ($image_name) ? $image_name : $this->fileName;
$fileName = $this->fileName; // FOR REASSIGNMENT INTO GLOBALIZED
2-DIM ARRAY FROM PROCEDURAL GLOBAL LIBRARY project_globals .inc.php
$msg = preg_replace('/#([^#]+)#/i', '$$1',
$successMsgArra y[$section][$action]);
$junk = eval('$' . 'msg = $msg;');
return $msg;
}
[/PHP]
Thanx
Phil
Comment