skibascott
IS-IT--Management
My goal here is to compare $phpdocnum (selected from a select list on the previous page)with the contents of $file_list. When executing the code here, my foreach loop finds no matches, even though I can see the value of $phpdocnum is exactly the same as a number of values in the $file_list(I have previously confirmed with an echo command the contents of $file_list). Funny thing is, when I manually declare the value of $phpdocnum to a value that I know is in $file_list, I get the desired results(a list of values in $file_list that match the string of $phpdocnum). Why is it that when I specify the value of $phpdocnum I get matches, but when I use the value I am getting from POST I do not get matches. I have confirmed that they hold the same value.
Code:
$list = "cd /mnt/sc_proc/video; ls *.wmv | sort";
exec($list,$file_list);
$phpdocnum = $_POST['PHPdocNum'];
$phpdocnum = substr_replace($phpdocnum, '-', 4, 1);
$phpdocnum = substr_replace($phpdocnum, '', 5, 1);
echo $phpdocnum."<br>";
foreach ($file_list as $value){
if ($phpdocnum == substr($value, 0, 6)){
echo $value."<br>";
}
}