$page = file_get_contents('template.txt');
$page = str_replace('old_string','new_string',$page);
print $page;
file_put_contents('newfile');
$A = file('file.txt');
foreach (file('file.txt') as $line){ $line = trim($line); print $line; }
$list = scandir('directory')
$directory = '/path/to/my/directory'; $scanned_directory = array_diff(scandir($directory), array('..', '.'));
foreach (scandir('directory') as $d){ if ($d[0]!=='.' && is_dir($d)){echo $d;} }
foreach (scandir('.') as $f){ if ($f[0]!=='.' && is_file($f)){echo $f;} }
$filelist = glob("/path/directory");
$filelist = glob("/path/directory/*.txt");
$filelist = glob("/path/directory/te*");
$filelist = glob("/path/directory/*.{jpg,gif,png}");
$filelist = glob("/path/directory/{*.jpg,*.gif,*.png}");
$fileslist = glob("/path/directory/*.{jpg,gif,png}", GLOB_BRACE);
$file = basename("/path/sudoers.txt");
$file = basename("/path/sudoers.txt",".txt");
$file = 'image.jpg'; $info = pathinfo($file); $file_name = basename($file,'.'.$info['extension']); echo $file_name;
$path_parts = pathinfo('/www/htdocs/inc/lib.inc.php'); echo $path_parts['dirname']; echo $path_parts['basename']; echo $path_parts['extension']; echo $path_parts['filename'];
echo pathinfo('/www/htdocs/index.html', PATHINFO_EXTENSION); // outputs html
echo pathinfo('/www/htdocs/index.html', PATHINFO_DIRNAME); // outputs /www/htdocs
echo pathinfo('/www/htdocs/index.html', PATHINFO_BASENAME); // index.html
echo pathinfo('/www/htdocs/index.html', PATHINFO_FILENAME); // outputs index
echo dirname("/etc/passwd"); \\ returns /etc
echo dirname("/etc/"); \\ returns /
echo dirname("."); \\ returns .
echo dirname("/usr/local/lib", 2); \\ returns /usr
echo dirname(__FILE__);