I'm trying to compare 2 string
. the first I get it from a array
, the second I get it from reading a directory. The problem is that I'm trying to compare that the name of the array matches that of the file that is reading and are identical.
String from an array length: 30 something is changing.mp3 // element of the array
File read from Directory length: 23 something is changing.mp3 // file
I'm doing it with this code to compare them and it always throws me out that it's false. I do not know why they are different.
echo "<br>Cadena proveniente de un array longitud de: ".strlen(($arrayPosiciones[$x])). " ". ($arrayPosiciones[$x]);
echo "<br>Archivo leido de Directorio longitud de:".strlen(($d)). " ".($d) ;
I think it's because of an accent problem or something like that. I have tried in many ways. Even the array I put the htmlentities()
since the elements that have tilde were badly encoded.
This fixes the problem, and the elements that are not shown in the tilde are fixed.
for($i=0; $i<count($arrayPosiciones); $i++){
$arrayPosiciones[$i]=htmlentities($arrayPosiciones[$i]);
}
What can I do? I'm going through a directory and compare that the current file is the same as the one in the $ arrayPositions
$ruta=$_REQUEST['ruta'];
$dir =scandir($ruta);
foreach($dir as $d){
if(substr($d,-3)=='Mp3' || substr($d,-3)=='mp3' || substr($d,-3)=='MP3' || substr($d,-3)=='WMA' || substr($d,-3)=
for( $x=0; $x<count($arrayPosiciones); $x++){
if($arrayPosiciones[$x]==$d){ echo "iguales"; }
.
.
.