At whatever point you have to avoid copy values from a one-dimensional array in PHP and you can take after with offered code to get one of a kind values in an avoid.
array_unique() method are utilized to avoid copy information from given array. Utilizing this situation it will keep first appearance data value in an array and removed other upcoming same value.
Two parameters which will be pass into array_unique() method to perform duplication discovering process, first determining an array which is required to filter and second one is optional indicating sorting type.
possible values optional parameters sorting type are:
- SORT_STRING – Default
- SORT_NUMERIC
- SORT_REGULAR
- SORT_LOCALE_STRING
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php $language_array = array("PHP","HTML","MySQL","PHP","CSS","Laravel","HTML"); echo "Before Dupicate finding : <br/> "; print_r($language_array); echo "<br/>"; echo "After Dupicate finding : <br/> "; print_r(array_unique($language_array)); // output as Array ( [0] => PHP [1] => HTML [2] => MySQL [4] => CSS [5] => Laravel ) - Here PHP & HTML are removed ?> |