I’m not sure what’s happening here. I am creating an array of ints and then using array_unique() to eliminate any duplicates values. For some reason, ints that were present before I called array_unique() are nowhere to be found afterward… at all. What I’m left with is an empty index where the missing int should be. Here’s the code:
[CODE]
<?php
// Create my array
$myArray = array(10, 15, 18, 77, 1, 15, 18, 77, 1, 15, 34);
// Print out all the contents of my array
for($i=0; $i<count($myArray); $i++)
echo ‘myArray[‘ . $i . ‘] = ‘ . $myArray[$i] . ‘<br>’;
// Create another array of only the unique values from the original array
$myUniqueArray = array_unique($myArray);
// Line break
echo ‘<br>’;
// Print out all the contents of my new array
for($i=0; $i<count($myUniqueArray); $i++)
echo ‘myUniqueArray[‘ . $i . ‘] = ‘ . $myUniqueArray[$i] . ‘<br>’;
?>
And the result of the above code is this:
[CODE]
myArray[0] = 10
myArray[1] = 15
myArray[2] = 18
myArray[3] = 77
myArray[4] = 1
myArray[5] = 15
myArray[6] = 18
myArray[7] = 77
myArray[8] = 1
myArray[9] = 15
myArray[10] = 34
myUniqueArray[0] = 10
myUniqueArray[1] = 15
myUniqueArray[2] = 18
myUniqueArray[3] = 77
myUniqueArray[4] = 1
myUniqueArray[5] =
What’s going on here? What happened to int 34?