Re: incrementing string value
| From: | Curt Zirzow | Date: | Fri, 25 Jul 2003 16:41:53 +0000 |
| Subject: | Re: incrementing string value | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156900@lists.php.net to get a copy of this message | ||
* Thus wrote Jeremy (jeremy@elijahgeneration.com):
> writing some client side javascript with some dynamic php, and I need to be
> able to print a dynamic number of variables to the javascript.
>
> I need to print:
> var a="";
> var b="";
> ...etc.
>
> Is there a way to increment a php $var much like $var++ would work?
If I understand this right you want to set a php $var to 'a' then
increment that so it becomes 'b', 'c', 'd', etc..
thus..
$var = ord('a');
while ($var <= ord('z') ) {
echo chr($var) , '="";', "\n";
$var++;
}
HTH,
Curt
--
"I used to think I was indecisive, but now I'm not so sure."