<?php

function VareXcept($url$varname)
{
    return 
"?$varname=".$_REQUEST[$varname];

}

?>
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<head>
<title>Hightlight</title>
</head>
<body>
</body>
</html>


<a href="?leht=SalaryHightlight.php">hightlight</a>
<?php

echo '<div style="margin-left: 200px">';
echo 
'<h3>1. leia 2018 palkade keskmine</h3>';
$salary=array(1220,1213,1295,1312,1298,1354,1296,1286,1292,1327,1369,1455);

$totalSalary=array_sum($salary);

$averageSalary=$totalSalary/count($salary);

echo 
'2018 aastas keskmine palk oli: '.$averageSalary;
echo 
'<br>';
echo 
'<h3> 2.tekita firma nimedes massiiv ja korrasta</h3>';

$firmad=array("Kimia","Mynte","Voomm","Twiyo","Layo","Talane","Gigashots","Tagchat","Quaxo","Voonyx","Kwilith","Edgepulse","Eidel","Eadel","Jaloo","Oyope","Jamia");

sort($firmad);

foreach (
$firmad as $firma)
{
    echo 
$firma.'<br>';
}



if (
$_SERVER["REQUEST_METHOD"] === "POST") {
    
// Get the company name to remove from the form
    
$removeName $_POST["removeName"];

    
// Use array_search to find the index of the company in the array
    
$index array_search($removeName$firmad);

    
// If the company is found, remove it from the array
    
if ($index !== false) {
        unset(
$firmad[$index]);
        
$firmad array_values($firmad); // Reindex the array
    
}
}

// Display the list of companies
foreach ($firmad as $firma) {
    echo 
$firma "<br>";
}



?>


<form method="post">
    <label for="removeName">Sisestage eemaldamiseks ettevõtte nimi:</label>
    <input type="text" name="removeName" id="removeName">
    <input type="submit" value="Emalda">
</form>

<?php

echo '<br>';
echo 
'<h3> 3.kuva kõige pikema riigi nime märkide arv</h3>';

$riigid=array(
    
"Indonesia",
    
"Canada",
    
"Kyrgyzstan",
    
"Germany",
    
"Philippines",
    
"Philippines",
    
"Canada",
    
"Philippines",
    
"South Sudan",
    
"Brazil",
    
"Democratic Republic of the Congo",
    
"Indonesia","Syria",
    
"Sweden",
    
"Philippines",
    
"Russia",
    
"China",
    
"Japan",
    
"Brazil",
    
"Sweden",
    
"Mexico",
    
"France",
    
"Kazakhstan",
    
"Cuba",
    
"Portugal",
    
"Czech Republic");

$maxLength 0// Initialize the maximum length to 0
$longestCountry="";
foreach (
$riigid as $country) {
    
$length strlen($country); // Get the length of the country name
    
if ($length $maxLength) {
        
$maxLength $length// Update the maximum length if a longer name is found
        
$longestCountry=$country;
    }
}

echo 
"Riigi pikim nimi {$maxLength} tähted, see on: {$longestCountry}.";

?>

<?php
echo '<h3>Hiina nimed</h3>';
echo 
'<br>';

$hiinaName=array("瀚聪","月松","雨萌","展博","雪丽","哲恒","慧妍","博裕","宸瑜","奕漳",
    
"思宏","伟菘","彦歆","睿杰","尹智","琪煜","惠茜","晓晴","志宸","博豪",
    
"璟雯","崇杉","俊誉","军卿","辰华","娅楠","志宸","欣妍","明美");
arsort($hiinaName);
echo 
'<h3>soreeri nimed kasvavas järjekorras</h3>';

foreach (
$hiinaName as $riseName)
{
    echo 
$riseName.'<br>';
}
echo 
'<br>';

echo 
'<h3>kuva esimene ja viimane nimi</h3>';

// Get the first name (assuming it's the first element in the array)
$firstName array_shift($hiinaName);

// Get the last name (assuming it's the last element in the array)
$lastName array_pop($hiinaName);

echo 
'Esimene nimi: ' $firstName '<br>';
echo 
'Viimane nimi: ' $lastName;



?>

<?php

echo '<br>';

echo 
'<h3>Google kasuta oringumootorit, et leida massiivi funktsioon, mis aitab<br> leida, kas kasutaja otsitav nimi on olemas</h3>';

$googleNames=array("Feake","Bradwell","Dreger","Bloggett","Lambole","Daish","Lippiett","
Blackie"
,"Stollenbeck","Houseago","Dugall","Sprowson","Kitley","Mcenamin",
    
"Allchin","Doghartie","Brierly","Pirrone","Fairnie","Seal","Scoffins",
    
"Galer","Matevosian","DeBlase","Cubbin","Izzett","Ebi","Clohisey",
    
"Prater","Probart","Samwaye","Concannon","MacLure","Eliet","Kundt","Reyes");




?>