Hi All
I have a very simple array which produces the following output when print_r() applied:
Array
(
[path] => Array
(
[0] => …//find_orphans/pics/hder.png
[1] => …//find_orphans/pics/Caure.PNG
[2] => …//find_orphans/pics/Caure2.PNG
[3] => …//ccount/reset.gif
[4] => …//ccount/delete.gif
[5] => …//ccount/edit.gif
[6] => …//ccount/line.gif
[7] => …//web_images/screen1.png
[8] => …//web_images/screen2.png
[9] => …//web_images/button.jpg
[10] => …//web_images/screen3.png
[11] => …//web_images/spacer.gif
)
[file] => Array
(
[0] => hder.png
[1] => Caure.PNG
[2] => Caure2.PNG
[3] => reset.gif
[4] => delete.gif
[5] => edit.gif
[6] => line.gif
[7] => screen1.png
[8] => screen2.png
[9] => button.jpg
[10] => screen3.png
[11] => spacer.gif
)
)
The foreach loop is as follows, again, pretty simple:
$count = 1;
$not_found = "";
$i = 0;
foreach($files[path] as $value){
$is_linked = check_for_link($value,$files[file][$i]);
echo $count.') '.$is_linked.'<br>';
$not_found .= $value.',';
$count++;
$i++;
}
The check_for_link() function takes the file name ($files[file][$i]) and checks to see if that string exists in a pre-existing text based file.
function check_for_link($file_path,$file_name){
$path = 'site_code.txt';
$contents = file_get_contents($path);
$file_path = str_replace('..//','../',$file_path);
if(!strpos($contents,$file_name)){
return $file_path;
}
}
The problem is when I try to echo the end result, it prints as follows:
1) …/find_orphans/pics/hder.png
2) …/find_orphans/pics/Caure.PNG
3) …/find_orphans/pics/Caure2.PNG
4)
5)
6)
7)
8) …/web_images/screen1.png
9) …/web_images/screen2.png
10) …/web_images/button.jpg
11) …/web_images/screen3.png
12) …/web_images/spacer.gif
Maybe I’m missing something painfully obvious, but why are 4,5,6 & 7 blank, has anyone come across this problem before? If so, I would be grateful to hear from you.