I've scanned a directory and now I've removed elements from an array that I didn't want to be there via a conditional. Now the problem I have is when I run the script via a for-loop to display the array (the elements I removed would display as blanks). So the problem is that say I removed an array at the second position like $array[2] - It will display as a blank. How do I get around that?
foreach($array as $key => $value) { if($value == ".." || $value == "." || $value == "error_log") { unset($array[$key]); } } PHP: Now when I use the for loop to display the array, it displays blanks for those values because when I remove the array, it actually removes that element number together. To avoid this I used array_values() function but it still leaves one blank. Edit: Here's the for-loop I'm using: $size = sizeof($array); for ($i = 0; $i <= $size; $i++) { echo $array[$i]; } PHP: