|
Posted by Yarco on 08/02/07 10:10
Well...Yes....but nothing is better than use const array.
I've already done such things:
$buf = range(0, 12); unset($buf[0]);
array_walk($buf, create_function('&$v, $k', '$v = date("M",
strtotime("2007-$k-01"));'));
print_r($buf);
.......what a pity php doesn't support const array...
On Aug 2, 4:44 pm, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
> Yarco wrote:
> > But cause $MONTH_NAMES is variable, someone could change the value.
>
> If you overload the class' __set() function you can effectively make it
> read-only. (Assuming you're using PHP 5.)
>
> Better though:
>
> function get_month_name ($n, $fmt='M')
> {
> $d = mktime(12, 0, 0, $n, 1, 1970);
> return date($fmt, $d);
> }
>
> --
> Toby A Inkster BSc (Hons) ARCS
> [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
> [OS: Linux 2.6.12-12mdksmp, up 42 days, 12:20.]
>
> PHP Encryption Class
> http://tobyinkster.co.uk/blog/2007/08/01/php-encryption-class/
Navigation:
[Reply to this message]
|