zad3 - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of zad3.php
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="widht=device-widht, initial-scale=1.0">
- <title>The green dress</title>
- </head>
- <body style="background-color: #73F182">
- <form action="" method="post">
- <h2 style="text-align: center; color: #10A749"> Welcome to the green color center !</h2>
- <p style=" color: #10A749">Enter the code you want to check : </p>
- <input type="text" name="code" id="code" style="color : #10A749">
- <input type="submit" name="submit" value="Check" style="color:#10A749">
- </form>
- </body>
- </html>
- <?php
- $matching_indexes = [];
- $input = "E3F5B7, 600B4A, 9DB75A, 44AFA7, E065C0, 37665B, 89B0F8, 37210D";
- $colors = explode(',', $input);
- var_dump($colors);
- $colors = str_replace(' ', '', $colors);
- var_dump($colors);
- foreach($colors as $index => $color) {
- if (strlen($color) === 6) {
- $red = hexdec(substr($color, 0, 2));
- $green = hexdec(substr($color, 2, 2));
- $blue = hexdec(substr($color, -2));
- if ($green > $red && $green > $blue) {
- $matching_indexes[] = $index;
- }
- }
- }
- var_dump($matching_indexes);
- ?>
File Description
- zad3
- PHP Code
- 15 Jan-2021
- 1.24 Kb
You can Share it:
Latest PHP Pastes