Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Problem 1. Removes Names
- //Write a script that takes as input two lists of names and removes from the first array all names given in the second array. The input //and output array are given as words, separated by a space, each list at a separate line. Examples:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <form method="post" action="RemoveNames.php">
- <input type="text" name="str1">
- <input type="text" name="str2">
- <input type="submit" value="GO">
- </form>
- </body>
- </html>
- <?php
- $string1=$_POST['str1'];
- $string2=$_POST['str2'];
- $arr1 = explode(" ", $string1);
- $arr2 = explode(" ", $string2);
- $difference = array_diff($arr1, $arr2);
- foreach($difference as $v){
- echo $v.' ';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement