Dynamically Created Variables and Values Attribution
Posted: 15 Oct 2013 02:12
Long time ago I needed to attribute values to dynamically created variables. Now and then I try to achieve the same since then but no success.
Is there a way, as of today's technowledge may allow this?
Another usage for this is to have groups of values distributed among such dynamic number of variables. Currently I resource to a random number of variables in hopes they won't be exceeded by the number of value groups script finds - which is error prone.
Is there a way, as of today's technowledge may allow this?
Code: Select all
$re = "";
$a = "ab;bc;cd";
foreach ($tk, "$a", ";") {
$op++;
// step;
$re = "$re" . '$' . "$tk = $op<crlf>";
}
$var = <<<hdc
$re
hdc;
// load ("$var", , s);
////////////////////debug
// text "$var";
////////////////////end of debug
// step;
// echo 1;
foreach ($tk, "$var", "<crlf>") {
// $op++;
// step;
// $re = "$re" . '$' . "$tk = $op<crlf>";
// step;
$varF = gettoken("$tk", 1, " = ");
$val = gettoken("$tk", 2, " = ");
// set eval($varF), "$val";
// set "$varF", "$val";
// step;
// set eval("$varF"), "$val";
// $varF = replace ("$varF", "$", ""); set "$" . "$varF", "$val"; // lazy code - getting rid of '$'
// $varF = replace ("$varF", "$", ""); set "$" . eval("$varF"), "$val"; // lazy code
// $varF = replace ("$varF", "$", ""); set "$" . eval($varF), "$val"; // lazy code
$varF = replace ("$varF", "$", ""); step; set "$" . "eval($varF)", "$val"; // lazy code
set $varF, "$val"; // $varF sould be $ab; $bc; $cd
}