note 45689 rejected from language.types.array by nlopess

From: Date: Wed, 15 Sep 2004 08:18:59 +0000
Subject: note 45689 rejected from language.types.array by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76724@lists.php.net to get a copy of this message
Note Submitter: net at bbs dot nju dot edu dot cn ---- It seems that PHP Compiler may be a little "weaker" than JavaScript to handle arrays. :) As you know, the weeks in Other languages can not be printed directly. As below will work well in JavaScript: <script> document.write ("[Sun],[Mon],[Tue],[Wed],[Thu],[Fri],[Sat]").split(",")[(new Date()).getDay()]; </script> [Sun],[Mon],[Tue],... in the code stands for characters in other languages. but, in php, i always get parse error :( <?php echo explode(',', '[Sun],[Mon],[Tue],[Wed],[Thu],[Fri],[Sat]')[date('w')]; ?> must i deal with it like below? <?php $temp = explode(',', '[Sun],[Mon],[Tue],[Wed],[Thu],[Fri],[Sat]'); echo $temp[date('w')]; ?>

« previous php.notes (#76724) next »