Re: $str[0] vs $str{0} was : generate random ascii string
| From: | Philip Olson | Date: | Sat, 01 Sep 2001 18:34:43 +0000 |
| Subject: | Re: $str[0] vs $str{0} was : generate random ascii string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-65614@lists.php.net to get a copy of this message | ||
It appears the only change you made was :
> $tmp .= $chars[mt_rand(0,$chars_len)];
From :
> > $tmp .= $chars{mt_rand(0,$chars_len)};
Which is strange. the [] use on strings has been depreciated in favor
of {} as of php4 but I don't know at what version {} came into being
exactly. What version of PHP are you running, php3? Or, does anyone know
much about this?
Anyway, glad it works :)
For informational purposes, this depreciation is stated here :
http://www.php.net/manual/en/language.types.string.php
And for those watching at home, am referring to :
$string = 'abc';
print $string[0]; // depreciated (might not work one day, when?)
vs.
print $string{0};
Both print 'a' though.
Regards,
Philip Olson