I have been looking for an answer for this, but none seem to actually help my specific situation. I'm trying to post a list of words and then remove the duplicate data (words) that come from the form.
For some reason I can't seem to get array_unique to work. PHP keeps giving me errors saying my post array is a string. But if I try using explode, it says I'm using an array. Really confused right now and very frustrated.
My code is simple:
if(!empty($_POST['keywords']))
{
$posted = $_POST['keywords'];
$posted = array_unique($posted);
echo $posted;
}
I'm not necessarily looking for an exact answer, but some guidance so I can better understand what I'm doing wrong here.
The form:
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<p>
<textarea name="keywords" rows="20" columns="120"></textarea>
</p>
<p>
<input type="submit" name="submit" />
</p>
</form>