I have tried for about three days and I just cannot figure this out. The goal is to have the user input numbers and have it filter out the unique numbers. Say the user inputs the numbers: 24, 24, 56, 23, 1, 3, 24 - the output should be 24, 56, 23, 1, 3. Up to this point, everything appears to be working. The only thing is when I hit the submit button, it doesn't return any values.
<!DOCTYPE html>
<!-- e9_1.php
Project1.php
-->
<html lang = "en">
<head>
<title> Project1.php </title>
<meta charset = "utf-8" />
<?php
function unique($strings) {
$uniqueStrings = array();
foreach ($strings as $string) {
foreach ($uniqueStrings as $uString) {
if ($string == $uString) break;
if(isset($_POST[‘numbers’])){
$str=preg_split("/[\s,]", $_POST['numbers']);
}
}
if ($string != $uString)
$uniqueStrings[] = $string;
}
return $uniqueStrings;
}
?>
</head>
<body>
<?php
$str = array();
$uStr=unique($str);
foreach ($uStr as $st)
print ("$st <br />");
?>
<br>
Enter Numbers: <br>
<form method = "POST">
<input type="text" name="numbers"/>
<input type="submit" name="Submit" />
</body>
</html>
unique()function.$_POST[‘numbers’]in your actual code, or is that just a copy/paste problem?foreach ($strings as $string)