Created
September 20, 2022 12:18
-
-
Save mosbth/2c6bb5abe89a12fd5b50a19fcffe9c8e to your computer and use it in GitHub Desktop.
kmom04 zoom timme 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre> | |
<?php | |
include('../config/config.php'); | |
$mikael = [ | |
"name" => "Mikael", | |
"age" => 42, | |
"luckynumber" => 3.14, | |
]; | |
$mikael["lives"] = "Skogen"; | |
print_r($mikael); | |
echo "Muppen heter " | |
. $mikael["name"] | |
. " och är " | |
. $mikael["age"] | |
. " år gammal med lyckonumret " | |
. $mikael["luckynumber"] | |
. "\n"; | |
$str = "<ul>"; | |
foreach ($mikael as $key => $value) { | |
$str .= "<li>$key ---- $value</li>"; | |
} | |
$str .= "</ul>"; | |
echo $str; | |
$str = "<ul>"; | |
foreach ($mikael as $value) { | |
$str .= "<li>$value</li>"; | |
} | |
$str .= "</ul>"; | |
echo $str; | |
?> | |
</pre> | |
<ul> | |
<?php foreach ($mikael as $key => $value) : ?> | |
<li><?= $key ?> ---- <?= $value ?></li> | |
<?php endforeach; ?> | |
</ul> | |
<?php | |
/* | |
$monthName = []; | |
$monthName[1] = "Januari"; | |
$monthName[] = "Februari"; | |
$monthName[] = "Mars"; | |
$monthName[] = "April"; | |
$monthName[] = "Maj"; | |
$monthName[] = "Juni"; | |
$monthName[] = "Juli"; | |
$monthName[] = "Augusti"; | |
$monthName[] = "September"; | |
$monthName[] = "Oktober"; | |
$monthName[] = "November"; | |
$monthName[] = "December"; | |
$monthNames = implode(", ", $monthName); | |
$monthNumToday = date("n"); | |
$monthToday = $monthName[$monthNumToday]; //$monthName[9] | |
echo "Alla månader: $monthNames.\n"; | |
echo "Idag är det månad: $monthToday\n"; | |
$weekday = [ | |
"Måndag", | |
"Tisdag", | |
"Onsdag", | |
"Torsdag", | |
"Fredag", | |
"Lördag", | |
"Söndag" | |
]; | |
var_dump($weekday); | |
print_r($weekday); | |
$dayNumToday = date("N"); | |
echo $dayNumToday . "\n"; | |
$dayToday = $weekday[$dayNumToday - 1]; | |
echo $dayToday . "\n"; | |
/* | |
$mikael = [ | |
"Mikael", | |
42, | |
"Sjöstaden", | |
3.14, | |
null, | |
true, | |
false | |
]; | |
$mikael[10] = "Grön moped"; | |
$mikael[] = "Mumintrollet"; | |
echo "<pre>"; | |
var_dump($mikael); | |
echo $mikael[0] . "\n"; | |
echo $mikael[1] . "\n"; | |
echo $mikael[11] . " kör en " . $mikael[10] . "\n"; | |
$num = count($mikael); | |
echo "I arrayen finns det $num element."; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment