ID: 33038
Updated by: [EMAIL PROTECTED]
Reported By: illicitcriminal at gmail dot com
-Status: Closed
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Windows
PHP Version: 4.3.10
New Comment:
No bug or new feature -> bogus.
Previous Comments:
------------------------------------------------------------------------
[2005-05-16 06:40:22] [EMAIL PROTECTED]
Already possible:
<?php
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$length = strlen($alphabet);
for ($i = 0; $i<$length; $i++) {
$$alphabet{$i} = $i;
}
echo $a.'-'.$b.'-'.$c.'-'.$A.'-'.$B.'-'.$C;
?>
result = 0-1-2-26-27-28
------------------------------------------------------------------------
[2005-05-16 04:18:54] illicitcriminal at gmail dot com
Description:
------------
I think it'd be VERY useful to be able to declare/state variables based
on the value of another variable. I've run into situations where it
would save me a bit of time if this were possible.
In "Reproduce Code", I'll show you a piece that would be useful for an
encryption function that I wrote.
Reproduce code:
---------------
/*
Giving Letters Numerical Values
*/
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$length = strlen($alphabet);
for ($cur=0;$cur<$length;$cur++){
$letter = substr($alphabet, $current, $current+1);
$numberVal = $current+1;
/*
This is where my idea comes in to play.
To be able to name the variable "a",
referred to as $a (and b,c,d so on...).
I've used the syntax ^$var to define the naming
of the variable dependant on the value of
$var (another variable)...
*/
^$letter = $numberVal;
}
echo $a.'-'.$b.'-'.$c.'-'.$A.'-'.$B.'-'.$C;
Expected result:
----------------
1-2-3-26-27-28
Actual result:
--------------
Probably an "unexpexted '^'" parse error.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33038&edit=1