Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1.Removes Names.
- <!DOCTYPE html>
- <html>
- <head>
- <title>Print Array</title>
- </head>
- <body>
- <form method="post">
- <label for="first">First list:</label>
- <input type="text" name="text_1" id="first">
- <br>
- <label for="second">Second list:</label>
- <input type="text" name="text_2" id="second">
- <br>
- <input type="submit" value="Go">
- </form>
- <?php
- $str_1 = $_POST['text_1'];
- $str_2 = $_POST['text_2'];
- $array_1 = explode(" ", $str_1);
- $array_2 = explode(" ", $str_2);
- $together = array_diff($array_1, $array_2);
- echo implode(" ", $together);
- ?>
- </body>
- </html>
- //2.Count of Letters.
- <!DOCTYPE html>
- <html>
- <head>
- <title>Count of Letters</title>
- </head>
- <body>
- <form method="post">
- <label for="letters">Letters:</label>
- <input type="text" name="str" id="letters">
- <br>
- <input type="submit" value="Go">
- </form>
- <?php
- $str = $_POST['str'];
- $array = explode(" ", $str);
- sort($array);
- echo '<pre>' . print_r(array_count_values($array), true) . '</pre>';
- ?>
- </body>
- </html>
- //3.Find All Matches.
- <!DOCTYPE html>
- <html>
- <head>
- <title>Find All Matches</title>
- </head>
- <body>
- <form method="post">
- <label for="text">Enter text:</label>
- <br>
- <textarea id="text" name="text" rows="10"></textarea>
- <br>
- <input type="submit" value="Go">
- </form>
- <?php
- $str = $_POST['text'];
- $str = strtolower($str);
- echo substr_count($str, 'em');
- ?>
- </body>
- </html>
- //4.Extract all Valid URLs.
- <!DOCTYPE html>
- <html>
- <head>
- <title>Extract all valid URLs</title>
- </head>
- <body>
- <form method="POST">
- <label for="text">Enter text:</label>
- <input type="text" name="str" id="text">
- <input type="submit" value="Go">
- </form>
- <?php
- $str = $_POST['str'];
- $reg = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
- preg_match_all($reg, $str, $url);
- echo '<pre>' . implode("\n", $url[0]) . '</pre>';
- ?>
- </body>
- </html>
- //6.Combine List of Letters.
- <!DOCTYPE html>
- <html>
- <head>
- <title>Combine List of Letters</title>
- </head>
- <body>
- <form method="post">
- <label for="first">First list:</label>
- <input type="text" name="text_1" id="first">
- <br>
- <label for="second">Second list:</label>
- <input type="text" name="text_2" id="second">
- <br>
- <input type="submit" value="Go">
- </form>
- <?php
- $str_1 = $_POST['text_1'];
- $str_2 = $_POST['text_2'];
- $array_1 = explode(" ", $str_1);
- $array_2 = explode(" ", $str_2);
- $unique = array_diff($array_2, $array_1);
- $together = array_merge($array_1, $unique);
- echo implode(" ", $together);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement