Hi there everyone!

I've got a problem with finding duplicate keys in my array creation.

I've tried a lot of different methods of handling it but none have worked. One attempt:

	/* New specifications */
	$i = 0;
	$dupe_name = array();
	UNSET($spec_array);
	WHILE(ISSET($_POST['specname'][$i])){

	if($_POST['specname'][$i] != '' AND $_POST['specval'][$i] != ''){

		if(array_key_exists($_POST['specname'][$i], $dupe_name)){
			echo 'Dupe found!';
		}

		$spec_array[$i]['name'] = htmlentities($_POST['specname'][$i], ENT_QUOTES);
		$spec_array[$i]['safename'] = mysqli_real_escape_string($link, $_POST['specname'][$i]);
		$spec_array[$i]['value'] = htmlentities($_POST['specval'][$i], ENT_QUOTES);
		$spec_array[$i]['safevalue'] = mysqli_real_escape_string($link, $_POST['specval'][$i]);

		$dupe_name[] = strtolower($spec_array[$i]['name']);


	}
	$i = ++$i;
}

The $dupe_name array holds the keys that I'd like to check against. I think this attempt didn't work because I've built the dupe array to hold the important stuff as a value and not a key. When I print it, it looks like this:

Array
(
[0] => fits
[1] => second value
[2] => fits
)

So then I tried another method:

if (in_array($_POST['specname'][$i], $dupe_name)) {

This also failed to find the duplicate.

Could someone tell me how I might resolve this issue? I can't seem to find the important stuff sitting in $dupe_name.

Thanks for your time!

    And I was so close.

    strtolower fixed my issue:

    if (in_array(strtolower($_POST['specname'][$i]), $dupe_name)) {

    Sorry for the false alarm!

      Write a Reply...