}
/**
 * Check if the images from the fruitmachine are equal. 
 * If the images are equal --> Output Jackpot!
 * @param type $images the letters from the fruitmachine
 */
function areValuesEqual($images)
{
    if (count(array_unique($images)) == 1) {
        echo "<p class='jackpot'>Jackpot!!</p>";
    }
}
echo "<div class=images>";
# Generate and show 3 images to the screen.
for ($i = 1; $i <= 3; $i++) {
    $randomImage = randomImage();
    echo "<div class='image'>" . $randomImage . "</div>";
    array_push($generatedImages, $randomImage);
}
# After the images have been generated, check if they are all equal
areValuesEqual($generatedImages);
echo "</div>";
# Template data
$the_title = "Week 6: Fruitmachine met afbeeldingen";
$the_content = ob_get_clean();
$show_source = array("16_fruitmachine_afbeeldingen.php" => __FILE__);
include "sidebar_array.php";
$sidebar_array = sidebar_array();
$sidebar_header = "Opdrachten PHP";
$assignment_description = "\n    <p>Herschrijf de functie uit opdracht 15 zodat je in plaats van 3 letters 3 \nlaatjes te zien krijgt. Als de 3 plaatje identiek zijn, dan krijgt je de \nboodschap 'Jackpot' getoond. </p>";
?>
    img {
        width: <?php 
echo $cell_width;
?>
px;
    }
</style>

<?php 
echo "<table>";
for ($i = 1; $i <= $table_rows; $i++) {
    echo "<tr>";
    for ($j = 1; $j <= $table_columns; $j++) {
        echo "<td>";
        # Show a random image in each table cell
        randomImage($images);
        echo "</td>";
    }
    echo "</tr>";
}
echo "</table>";
/**
 * @param array $afbeeldingen_array Array of arrays that contain images, 
 * the alt-text and a hyperlink. 
 */
function randomImage($images)
{
    $array_length = count($images);
    $random_value = mt_rand(0, $array_length - 1);
    $current_image = $images[$random_value];
    echo "<a href=\"images/{$current_image['0']}\"> <img src=\"images/{$current_image['0']}" . "\" alt=\"{$current_image['1']}\"></a>";
Example #3
0
    <meta name="keywords" content="design, code, art, php, web, python, html, css, unix, linux, bsd, freebsd">
    <meta name="author" content="Philip Andersen">

    <!-- Mobile -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

    <!-- Stylesheets -->
    <link rel="stylesheet" media="all" href="css/normalize-3.0.3.css">
    <link rel="stylesheet" media="only screen" href="css/font-awesome.min.css">
    <link rel="stylesheet" media="only screen" href="css/style.css">
    <link rel="stylesheet" media="only screen and (min-width: 60em)" href="css/animate.css">

    <?php 
// If photos exists, use it as background
if ($image = randomImage()) {
    echo "<!-- Random photo generator -->\n    <style>\n    @media only screen {\n        body, #blur {\n            background: url('../{$image}') no-repeat center center fixed;\n            -webkit-background-size: cover;\n               -moz-background-size: cover;\n                 -o-background-size: cover;\n                    background-size: cover;\n        }\n    }\n    </style>\n";
}
?>
</head>
<body>

    <!-- vCard -->
    <div id="vcard" class="flexbox-container">

        <!-- Gaussian Blur layer -->
        <div id="blur" class="animated fadeIn"></div>

        <!-- Header/Sidebar -->
        <section id="vcard-sidebar" class="animated fadeInRight">