Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php howto ignore file with BOM

<?php 
function fopen_utf8 ($filename) { 
    $file = @fopen($filename, "r"); 
    $bom = fread($file, 3); 
    if ($bom != b"xEFxBBxBF") 
    { 
        return false; 
    } 
    else 
    { 
        return true; 
    } 
} 

function file_array($path, $exclude = ".|..|design", $recursive = true) { 
    $path = rtrim($path, "/") . "/"; 
    $folder_handle = opendir($path); 
    $exclude_array = explode("|", $exclude); 
    $result = array(); 
    while(false !== ($filename = readdir($folder_handle))) { 
        if(!in_array(strtolower($filename), $exclude_array)) { 
            if(is_dir($path . $filename . "/")) { 
                                // Need to include full "path" or it's an infinite loop 
                if($recursive) $result[] = file_array($path . $filename . "/", $exclude, true); 
            } else { 
                if ( fopen_utf8($path . $filename) ) 
                { 
                    //$result[] = $filename; 
                    echo ($path . $filename . "<br>"); 
                } 
            } 
        } 
    } 
    return $result; 
} 

$files = file_array("."); 
?>
Comment

PREVIOUS NEXT
Code Example
Php :: empty func php 
Php :: laravel hash password sample 
Php :: php namespaces 
Php :: public path() does not work on live server laravel. Problem with public path on live server 
Php :: Laravel Nested whenLoaded 
Php :: accept method in jquery 
Php :: array random php 
Php :: entrust laravel 
Php :: foreach and forelse empty 
Php :: laravel get data from model to controller 
Php :: php pass 2 date value to javascript 
Php :: stampare array php foreach 
Php :: action php self 
Php :: php trait example 
Php :: symfony get locale from request in controller 
Php :: html windows logo 
Php :: php serve a video (THE ONLY WORKING CODE) 
Php :: text to sha256 converter in laravel 
Php :: $faker-paragraph 
Php :: laravel validation on update 
Php :: login with email or username codeigniter 4 
Php :: test in laravel 
Php :: how to enable autoreload on save laravel 
Php :: php explode and get first value 
Php :: Laravel artisan command to create model plus migration 
Php :: wordpress theme basics including CSS and js 
Php :: submit form and show results on same page without refresh 
Php :: cakephp sql query 
Php :: if else in php 
Php :: Laravel catch TokenMismatchException 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =