I want to remove duplicate values from array. I know to use array_unique(array)
function but faced problem in foreach
loop. This is not a duplicate question because I have read several questions regarding this and most of them force to use array_unique(array)
function but I have no idea to use it in foreach
loop. Here is my php function.
$images = scandir($dir);
$listImages=array();
foreach($images as $image){
$listImages=$image;
echo substr($listImages, 0, -25) ."<br>"; //remove last 25 chracters
}
How to do this?