I want to remove specific value of array. this's my code:
HTML
<form action="" method="post">
<input type="text" name="user">
<input type="submit" value="Watch">
</form>
PHP
$user='';
if ( isset ( $_POST['user'] ) ) { $user = $_POST['user']; }
$dir = "images/".$user.'/';
$dh = opendir ( $dir );
while ( false !== ($filename = readdir( $dh ) ) ) {
$files[] = $filename;
}
$files = array_diff ( $files, array('.','..') );
$e = count($files);
for ( $i=0; $i<$e; $i++ ) { echo $files[$i]; }
Output
user/.
user/..
user/HTML.txt
user/CSS.txt
user/JavaScript.txt
i tried array_diff()
to remove '.'
and '..'
.
i get noticed offset 0 on for value by latest WAMP.
and how to make While version to For version loop that use opendir, and readdir?