I want to get a value by the function with forms as the user input but I don't think I'm doing it right can anybody help me.
The code is like when enter number 1 in the form then it will output it by the days like Sunday.
Output:-
Enter days values between (0-6): 1
The day is Monday.
My Code:-
<?php
function day_of_week($week){
$week = $_POST['week'];
$week = array(0 => Sunday, 1 => Monday, 2 => Tuesday, 3 => Wednesday, 4 => Thursday, 5 => Friday, 6 => Saturday);
return $week;
}
if(isset($_POST['submit'])){
$value = $_POST['value'];
echo "The day is " . day_of_week($value);
}
?>
<form method="POST" action="">
<label>Enter days value between (0-6):</label>
<input type="text" name="value">
<input type="submit">
</form>
I search some code and some code the week can be assigned like
date('w');
if(date('w') == 1){
echo "its monday baby";
}
or also in case code. But I'm not too sure how to actually call the value properly and assigning. Which one is better for assigning, array or date() or case for assigning?
Do help me out to explain why my value is not showing properly too.
Appreciate anyone's helps thank you so much.