Array and Glob Doubts

Asked

Viewed 50 times

0

I’m wanting to pick up 2 foreach entries and file one based on another, for example.

in one foreach I have the value "stackoverflow" and in the other I also have the same, and then one cancels the other and then the 2 do not appear in echo. what am I doing:

$filee2 = array();
glob("C:/Users/raphael/Downloads/Videos/Lives Baixadas/Converter/*/*.mp4") as $filee) {
    $filee2 = array($filee => $filee);
}

foreach (glob("C:/Users/raphael/Downloads/Videos/Lives Baixadas/Converter/*.ts") as $filename) { 

$file1 = str_replace('.mp4','',$filee2);
$file2 = explode("/", $file1);
    
    print_r($filee2).'<br>';
    
$file3 = str_replace('.ts','',$filename);
$file4 = explode("/", $file3);
    if( $file4[7] == $file2[8] ){

    }else{

?>

    <li><form method="post" enctype="multipart/form-data">
        
        <?=str_replace('C:/Users/raphael/Downloads/Videos/Lives Baixadas/Converter/', '', $filename)." - Tamanho: " . formatSizeUnits(filesize($filename))?>
        <input type="hidden" name="converternome" value="<?=str_replace('C:/Users/raphael/Downloads/Videos/Lives Baixadas/Converter/', '', $filename)?>">
        <input type="submit" name="converter" value="converter">
               
    </form><br /></li>
        
<?php
        }//Fim do if
}//Fim do foreach filename
?>

1 answer

0

I got

<?php
$convertidos = array();
foreach (glob("C:/Users/raphael/Downloads/Videos/Lives Baixadas/Converter/*/*.mp4") as $filee) {
    
    $file1 = str_replace('.mp4','',$filee); 
    $file2 = explode("/", $file1);  
    
    $convertidos[] = $file2[8];

}

foreach (glob("C:/Users/raphael/Downloads/Videos/Lives Baixadas/Converter/*.ts") as $filename) { 
    
$file3 = str_replace('.ts','',$filename);
$file4 = explode("/", $file3);
    
    if(in_array($file4[7], $convertidos)){
    }else{

?>

    <li><form method="post" enctype="multipart/form-data">
        
        <?=str_replace('C:/Users/raphael/Downloads/Videos/Lives Baixadas/Converter/', '', $filename)." - Tamanho: " . formatSizeUnits(filesize($filename))?>
        <input type="hidden" name="converternome" value="<?=str_replace('C:/Users/raphael/Downloads/Videos/Lives Baixadas/Converter/', '', $filename)?>">
        <input type="submit" name="converter" value="converter">
               
    </form><br /></li>
        
<?php
        }//Fim do if
}//Fim do foreach filename
?>

I used In_array and managed to do what I needed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.