2

here's something that confuse me, the code is the same but this got this undefined offset, and here's the code :

<?php
$day = array("Sunday"    => "Minggu",
               "Monday"    => "Senin",
               "Tuesday"   => "Selasa",
               "Wednesday" => "Rabu",
               "Thursday"  => "Kamis",
               "Friday"    => "Jumat",
               "Saturday"  => "Sabtu");
$elemen = date(1);
echo("Today is : $day[$elemen]");

?>

the code is the same on my friend but mine show this undefined offset, but him show Today is bla bla without any error. looking forward for the hint. thanks i really appreciate it..

2
  • 2
    use date(l) not 1. Its "L". Commented Apr 6, 2015 at 6:03
  • No response from peoples asking question, even after asking. frustrating. deleting my answer Commented Mar 24, 2016 at 19:50

2 Answers 2

1

date accepts a format string, which 1 isn't. I'm guessing you tried to use the format to retrieve today's name, which would be 'l' (a lower case L):

$elemen = date('l');
Sign up to request clarification or add additional context in comments.

2 Comments

It again gives:-Notice: Use of undefined constant l - assumed 'l' in your php file path on line 9 Today is : Senin
@anantkumarsingh got caught up explaining the formatting I completely forgot about quoting the 'l'. Fixed, see my edited answer.
0

Try

(!empty($day[sunday]))

This check would possibly solve your problem

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.