0

in my code im using a array_unique to remove the duplicates in my array but when i do the variables in my array get the put in their original posiotions from the old array is there anyway do prevent this.

Array $b:

Array ( [0] => a [1] => a [2] => b ) 

$SlideShowNames = array_unique($b);

output:

Array ( [0] => a [2] => b )

as you can see the b stays in postion 2 i would like it to be in position 1

1
  • Using array_values. Commented May 25, 2018 at 7:25

1 Answer 1

5
$slideShowName = array_values(array_unique($b));

is what you're looking for

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.