commit existing workshops

This commit is contained in:
boris
2024-10-16 09:24:22 +01:00
parent 803c11f46d
commit 4070dc5367
56 changed files with 2803 additions and 0 deletions

8
workshop3/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

8
workshop3/.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/workshop3.iml" filepath="$PROJECT_DIR$/.idea/workshop3.iml" />
</modules>
</component>
</project>

20
workshop3/.idea/php.xml generated Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.3" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

6
workshop3/.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
</component>
</project>

8
workshop3/.idea/workshop3.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
workshop3/emoji.php Normal file
View File

@@ -0,0 +1,6 @@
<?php
for ($i = 128512; $i < 128592; $i++) {
$hex = dechex($i);
echo "Icon for 0x$hex is '&#x$hex'";
echo "<br>";
}

33
workshop3/operators.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
$temp = array(78, 60, 62, 68, 71, 68, 73, 85, 66, 64, 76, 63, 75, 76, 73, 68, 62, 73, 72, 65, 74, 62, 62, 65, 64, 68, 73, 75, 79, 73);
function smallestTemp($temp)
{
sort($temp, SORT_NATURAL);
for ($i = 0; $i < 7; $i++) {
$smallestTemp[$i] = $temp[$i];
}
return implode(", ", $smallestTemp);
}
function largestTemp($temp) {
rsort($temp, SORT_NATURAL);
for ($i = 0; $i < 7; $i++) {
$largestTemp[$i] = $temp[$i];
}
return implode(", ", $largestTemp);
}
function calcAvgTemp($temp) {
$totalTemp = 0;
foreach ($temp as $value) {
$totalTemp += $value;
}
return round( ($totalTemp / count($temp) ), 1 );
}
echo "Average Temperature is : " . calcAvgTemp($temp);
echo "<br>";
echo "List of seven lowest temperatures : " . smallestTemp($temp);
echo "<br>";
echo "List of seven highest temperatures : " . largestTemp($temp);

46
workshop3/strings.php Normal file
View File

@@ -0,0 +1,46 @@
<html>
<head>
<title>Train Listings</title>
</head>
<body>
<table>
<tr>
<th>Title</th>
<th>Price</th>
</tr>
<?php
$url = "http://www.classifiedsteam.co.uk/index.php?page=search&sCategory=10";
$string = file_get_contents($url);
$dom = new DOMDocument();
$dom->loadHTML($string);
$xpath = new DOMXPath($dom);
$titles = $xpath->query("//a[contains(@class, 'title')]");
$prices = $xpath->query("//span[contains(@class, 'currency-value')]");
for ($i=0; $i<$titles->length; $i++) {
$title = $titles->item($i)->textContent;
$link = $titles->item($i)->getAttribute('href');
$price = $prices->item($i)->textContent;
echo "<tr>\n";
echo "<td><a href='$link' title='$title'>$title</a></td>\n";
echo "<td>$price</td>\n";
echo "</tr>\n";
}
?>
</table>
</body>
<style>
html {
font-family: "DejaVu Sans";
}
table, td, th {
border: 1px solid;
border-collapse: collapse;
}
td, th {
padding: 8px 6px 8px 6px;
}
a {
text-decoration: none;
}
</style>
</html>