note 45689 added to language.types.array
| From: | net at bbs dot nju dot edu dot cn | Date: | Wed, 15 Sep 2004 07:35:48 +0000 |
| Subject: | note 45689 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76711@lists.php.net to get a copy of this message | ||
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')];
?>
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45689
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45689&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45689&report=yes
Search -- http://master.php.net/manage/user-notes.php